by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 09 19:19
    CastixGitHub synchronize #19
  • Jul 08 21:55
    CastixGitHub synchronize #19
  • Jul 08 21:48
    CastixGitHub synchronize #19
  • Jul 08 21:35
    CastixGitHub synchronize #19
  • Jul 08 21:20
    CastixGitHub synchronize #18
  • Jul 08 21:14
    CastixGitHub opened #19
  • Jul 08 21:14
    CastixGitHub opened #18
  • Jul 01 07:41
    CastixGitHub synchronize #129
  • Jun 30 16:23
    CastixGitHub synchronize #129
  • Jun 30 16:21
    CastixGitHub opened #129
  • Jun 19 19:48

    brondsem on 0.10.2

    (compare)

  • Jun 19 19:48

    brondsem on master

    Version 0.10.2 (compare)

  • Jun 19 19:20

    brondsem on master

    MIM: Avoid errors from _ensure_… Merge pull request #25 from Tur… (compare)

  • Jun 19 19:20
    brondsem closed #25
  • Jun 19 19:17

    brondsem on master

    Use our __insert not pymongo pa… Merge pull request #24 from Tur… (compare)

  • Jun 19 19:17
    brondsem closed #24
  • Jun 18 21:32
    brondsem opened #25
  • Jun 18 21:30

    brondsem on mim_dot_dollar_wrong

    MIM: failing test for positiona… (compare)

  • Jun 18 21:28

    brondsem on mim_dot_dollar

    MIM: Avoid errors from _ensure_… (compare)

  • Jun 18 21:26

    brondsem on mim_dot_dollar

    MIM: Avoid errors from _ensure_… (compare)

Alessandro Molina
@amol-
You can see that tests in test_root can use REMOTE_USER
while the one under test_authentication do use real authentication and cookies
Joe Knapka
@jknapka
Thanks, @amol_ . I found the problem, my test fixture was causing an exception that rolled back its transaction. All the TG machinery around auth forging is working as expected.
Joe Knapka
@jknapka
Hello all, I am trying to add i18n to my TG2.4 application. This seems to have broken many of my test cases with the following exception while calling ugettext():
Traceback (most recent call last):
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/jk/Software/unter/src/tg/unter/unter/tests/functional/test_multi_alerts.py", line 86, in test_0_oneVolunteerEvent
    self.sendAlert(ev_id=1)
  File "/Users/jk/Software/unter/src/tg/unter/unter/tests/functional/test_multi_alerts.py", line 82, in sendAlert
    need.checkOneEvent(model.DBSession,ev_id=ev_id,honorLastAlertTime=False)
  File "/Users/jk/Software/unter/src/tg/unter/unter/controllers/need.py", line 27, in checkOneEvent
    debugTest(_("Checking need event {} {}").format(ev_id,notes))
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/TurboGears2-2.4.0a1-py3.7.egg/tg/i18n.py", line 87, in ugettext
    return tg.translator.gettext(value)
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/TurboGears2-2.4.0a1-py3.7.egg/tg/support/objectproxy.py", line 19, in __getattr__
    return getattr(self._current_obj(), attr)
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/TurboGears2-2.4.0a1-py3.7.egg/tg/request_local.py", line 233, in _current_obj
    return getattr(context, self.name)
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/TurboGears2-2.4.0a1-py3.7.egg/tg/support/objectproxy.py", line 19, in __getattr__
    return getattr(self._current_obj(), attr)
  File "/Users/jk/Software/py3-venv-2/lib/python3.7/site-packages/TurboGears2-2.4.0a1-py3.7.egg/tg/support/registry.py", line 72, in _current_obj
    'thread' % self.____name__)
TypeError: No object (name: context) has been registered for this thread
I don't know where to begin fixing this. Advice would be appreciated. Thanks!
(Note, need.py is not an actual TG controller, it's just a file with some utility methods that get tested separately.)
Joe Knapka
@jknapka
I guess that tg.uggettext () depends on being inside a request, so probably I need to switch to using the GNU gettext API inside these utility files.
Joe Knapka
@jknapka
...Actually using the raw gettext API seems like a bad idea, since this utility code will then need to jump through hoops to figure out what the request's locale is when it is running inside a web request. So... it looks like I need to figure out how to "register an object named context for this thread" in my non-web-request test code. I guess that's probably handled by middleware, usually?
Joe Knapka
@jknapka
Looking at the TG i18n docs, it seems to say that lazy_ugettext() should work without an active request. However, replacing all the _() calls with l_() calls in my utility code does not solve the problem. For the moment I've "solved" the problem by using my own _() and l_() functions that check whether a context exists, and if not, returns the untranslated string. This doesn't seem like an especially good solution, though.
Alessandro Molina
@amol-
@jknapka yeah, TG can't resolve the translation if it doesn't know the current request. Because the language you want to translate to is the one provided by the browser usually. But lazy_ugettext can solve that problem if you don't try to resolve the string. Like if you try to print, show or concatenate the string it will resolve it.
Nils Philippsen
@nphilipp

@jknapka another idea would be to mock-patch _() in the "offending" module, e.g. like this (careful, untested):

from unittest.mock import patch
...
    @patch('unter.controllers.need._', lambda x: x)
    def test_0_oneVolunteerEvent(self, ..., patched_gettext):
        ...
        self.sendAlert(ev_id=1)
        ...

This will replace _() in unter.controllers.need with a lambda that simply returns the untranslated text while the decorated test method is executed (and pass it into the method as patched_gettext in case you want to inspect it in your test).

Alessandro Molina
@amol-

Ah, if we are talking about tests, I think this is what you are looking for: https://turbogears.readthedocs.io/en/latest/turbogears/testing.html#testing-outside-controllers

So that you have a translator in place even without a request

Nils Philippsen
@nphilipp
I knew there was something more straightforward! :grinning:
Joe Knapka
@jknapka
Ah yes, that is exactly what I was looking for. Probably I should just read all the TG docs from start to finish :-P
Alessandro Molina
@amol-
TG trending
2.4 release made TG pop up in trending repositories on GitHub o_O
Nils Philippsen
@nphilipp

2.4 release

:raised_hands:

Berthoud Yannick
@YannickBerthoud_twitter
Hi, I need your help to change de login options to use the email_adress field. The doc refer to use "ApplicationAuthMetadata" in app_cfg.py but I don't see any options about this :(
Alessandro Molina
@amol-
It's not an option per se, but you can easily achieve that by changing the ApplicationAuthMetadata class in app_cfg to use .email_address wherever it is using .user_name
Berthoud Yannick
@YannickBerthoud_twitter
ah, ok, thanks !
it's working, good job ! thanks a lot
kevinhuang
@huangzhuo492008824
gearbox.png
Hello all, when I try run "gearbox serve" , it return error:
Advice would be appreciated. Thanks!
Joe Knapka
@jknapka
It appears to be a problem with SQLAlchemy. Check that you have updated it to the version TG needs. With TG2.4 I have SQLAlchemy 1.3.7.
Nils Philippsen
@nphilipp
It seems something is broken with the installed SQLAlchemy, not its version -- sqlalchemy.log implements the Identified class itself.
Joe Knapka
@jknapka
Kevin, if you're not installing TG and its friends in a virtualenv, I would recommend you do that. Start with freshly-installed everything (including SQLAlchemy) in a virtualenv and see if you see the same problem.
Rich Kucera
@kucerarichard
Newbie here, my minimal configurator doesn't give me access to tg.request.validation as documented. Should I duplicate my post here from the mailing list? Where do I begin to troubleshoot?
Alessandro Molina
@amol-
I saw the post on the ML coming, didn't yet have a chance to respond. I hope to be able to respond soon.
AppGlobal btw is not configured in minimal mode if I remember correctly.
I just need to have a few minutes spare to try your snippet and come back to you with the proper solution
Alessandro Molina
@amol-
Those messages you see should be warnings and are unrelated to tg.request.validation
Rich Kucera
@kucerarichard
@amol- Thank you Alessandro! I forked the gist should be able to try tomorrow...
Alessandro Molina
@amol-
FYI, TurboGears 2.4.1 was released, here is the release announcement: https://twitter.com/turbogearsorg/status/1168987947867279369
Rich Kucera
@kucerarichard
@amol- thanks! for the help. Mine was such a basic import tg error and plus messed up comprehension syntax..
Alessandro Molina
@amol-
:+1:
yeah, I wasn't sure if you were trying to make a list of dicts or a dict with all the entries given the comprehension you wrote
Mengu Kagan
@mengu
hi all
Rich Kucera
@kucerarichard
@mengu hello!
Is it possible to express compound validation with the validate decorator? For example I have three parameters and Any of them(at least one of them) need to have a number.
Rich Kucera
@kucerarichard
nvmd I had to reread the doc, the answer is yes but but for multiple validators on the same parameter, not multiple parameters...
Alessandro Molina
@amol-
Hi @mengu great to see you around :)
@kucerarichard if you feel is not obvious in the doc how to do something, feel free to submit a PR. I'll gladly merge it!
Rich Kucera
@kucerarichard
Will do! I finally figured out I need schema validation (haven't done it yet, will take notes...)
Rich Kucera
@kucerarichard
(btw I tried using bottlepy for an hour, got bored and dropped it, so hopefully will make more progress on the app going ahead with tg2 now..., I spent two weeks comparing frameworks and got nowhere finally tried bottle and didn't like the code I'd end up writing).
Mengu Kagan
@mengu
@amol- heard you guys were hanging around here :)
@kucerarichard, what do you expect a framework to help you with?
Rich Kucera
@kucerarichard
@mengu depends on what I'm trying to do, so far I like the minimal mode of tg2 and the enigmatic formencode integration, I expect to go fullstack sometime and glad that is an option.
Alessandro Molina
@amol-
@kucerarichard for most use cases you don't even need to involve Formencode, in many cases builtin Convert is enough: https://turbogears.readthedocs.io/en/latest/reference/classes.html#tg.validation.Convert
Rich Kucera
@kucerarichard
Interesting! But I'll need formencode, I found some examples I'll see if I can boil it down into a PR. There was one crucial example that showed me how to do it.