Thank you for your answer. I don't know why my initial post was deleted, I 
would have answered it sooner...

The origin of the problem was that I imported functions from a model file 
in a controller file.
I usually do that prefixing it by 
if 0:
   from <model file> import <function or class>
in order to make import errors disappear in Eclipse, so that I see the real 
errors ; but in this case I had forgotten this "if 0:"

And as imported modules do not have access to global variables, so was it 
for this imported model.

So, imports are dangerous :-)

Le mardi 20 novembre 2012 08:09:08 UTC+1, Johann Spies a écrit :
>
> On 19 November 2012 15:53, Cédric Mayer <argl...@gmail.com 
> <javascript:>>wrote:
>
>>
>>   File 
>> "C:/Users/cedric/projets/LACT/eclipse/Lactw221/web2py/applications/lact/models/a34_lact_running_modes.py"
>>  
>> <http://127.0.0.1:8000/admin/default/edit/lact/models/a34_lact_running_modes.py>,
>>  line 43, in on_end
>>
>>     session.flash = T('Serie finished! Thank you!')
>> NameError: global name 'T' is not defined
>>
>> de.on_end()
>>
>> As you see, a34_running_modes.py is in the 'models' folder. But a 
>> function from it called from the controller doesn't know of 'T' which is 
>> global !
>> Previously I had the same error in some other functions with 'auth' 
>> (defined in a12_db.py, so still before) and 'request', which I solved by 
>> passing 'auth' or 'request' as function arguments (even if I find it not 
>> very nice...), as they are available in the controller function.
>>
>> But if even T is not known, I cannot pass all usual global variables as 
>> arguments to every function present in 'models' folder.
>>
>> Do I miss something ? Like a "what-to-check-if-you want-to-upgrade 
>> web2py" documentation ? (even if I thought web2py was fully backward 
>> compatible, this is why I choose it)
>>
>>
> The problem might be the name of your model.  If I remember correctly the 
> models are imported in alphabetical order.  In the default db.py (like in 
> the welcome app) some important stuff gets imported that should happen 
> before other models are loaded.
>
> As an experiment try a changed name for your model which starts with a 
> character > 'd'.
>
> Otherwise do import the necessary stuff from gluon in your model.
>
> e.g.
>
> from gluon import T
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>
>

-- 



Reply via email to