On Dec 31, 2010, at 8:06 PM, DenesL wrote:
>
>> The ideal solution would be one that allowed using T() normally in gluon (at
>> least in code that's invoked from an application); that avoids the T=T
>> requirement.
>>
>> My conjecture is when Python compiles the gluon code, it binds T references
>> (to what? that's the hole in my theory) at compile time, and thus ignores
>> the presence of T in globals. Making T an argument forces Python to defer
>> binding.
>>
> The funny part is that T is in environment (!!!?) so
> exec ccode in environment
> should work, I don't see why it does not.
>
OK, here's part of the riddle solved. If I call T in gluon.validators, and run
web2py:
File "/Users/jlundell/Projects/web2py/web2py-hg/gluon/validators.py", line
123, in IS_MATCH
def __init__(self, expression, error_message=T('invalid expression')):
NameError: name 'T' is not defined
So no funny business with binding; it just doesn't compile.