------------------------------------------------------------------------------------------------------------
Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import turbogears
>>> turbogears.validators.Int( ).to_python('5')
5
>>> turbogears.validators.Int( ).to_python('x')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg/formencode/api.py",
line 368, in to_python
value = tp(value, state)
File "/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg/formencode/validators.py",
line 924, in _to_python
raise Invalid(self.message('integer', state),
File "/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg/formencode/api.py",
line 194, in message
return trans(self._messages[msgName], **self.gettextargs) % kw
TypeError: ugettext() got an unexpected keyword argument 'domain'
>>>
----------------------------------------------------------------------------------------------------------
Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26)
[GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import turbogears
>>> turbogears.validators.Int( ).to_python('x')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg/formencode/api.py",
line 368, in to_python
value = tp(value, state)
File "/usr/lib/python2.5/site-packages/FormEncode-0.7.1-py2.5.egg/formencode/validators.py",
line 925, in _to_python
value, state)
formencode.api.Invalid: Please enter an integer value
>>>
-----------------------------------------------------------------------------------------------------------
As you can see the second session worked as expected but the first one
-- which only differs from the second one by doing first a validation
that goes through -- is totally weird. Can anyone explain?
Cheers,
Daniel
I recently had some formencode problems as well, and upgrading to
formencode 0.9 helped.
-- Chris
Upgraded to 0.9 and the same issue remains. It's very misterious,
appears to be some memory effect there since the only difference
between the two calling sequences is that in one case there was a call
before the problematic one and in the other not.
BTW can anyone reproduce it?
Just tried it on Windows and got the same effect. It happens only if you
run the commands in the shell, not if you run them as a script.
-- Chris
Seems to have something to do with the obscure trickery of translating
messages in FormEncode and TurboGears. There is a special version of
gettext in Turbogears that can handle an additional domain parameter.
FormEncode and TurboGears switch between the gettext versions. The
Validator class has a class attribute dictionary gettextargs which is
used as a parameter for gettext. If the standard version of gettext is
called with that parameter, it throws that exception.
-- Chris
Opened a new ticket on this: http://trac.turbogears.org/ticket/1671