you can use session.

http://zerp.ly/rochacbruno
Em 21/05/2012 22:48, "Maduranga Liyanage" <[email protected]>
escreveu:

> Thank you very much Anthony.
> I will read up on the cache.
>
>
> On Tue, May 22, 2012 at 1:37 AM, Anthony <[email protected]> wrote:
>
>> Controller and model files are not Python modules. Rather, they are
>> re-executed (in a separate thread) on each request, so a change you make to
>> a global variable in one request will not affect other requests. You
>> probably want to use the cache for this purpose:
>> http://web2py.com/books/default/chapter/29/4#cache.
>>
>> Anthony
>>
>>
>> On Monday, May 21, 2012 12:09:14 PM UTC-4, Madu wrote:
>>>
>>> Hi,
>>>
>>> I thought this could be trivial but so far I couldn't figure out how to.
>>> All I need to do is have a global variable in default.py. When I call
>>> one method it will store a value in this variable, and later another method
>>> will use it. What I have is something like this:
>>>
>>>
>>> ------- default.py-----
>>> value = 0
>>>
>>>
>>> def saveValue():
>>>         global value
>>>         value = 1
>>>
>>>
>>> def showValuel():
>>>         return dict(entries=value)
>>>
>>> Then I thought the default.py module maybe going out of scope when the
>>> method returns, so I put 'value' in db.py, since variables defined in db.py
>>> are available globally. But I still get the value that I define in db.py,
>>> not the modified value in saveValue().
>>>
>>> Could you please tell me if there is a recommended way in web2py to
>>> have global values?
>>>
>>> Thank you.
>>>
>>
>

Reply via email to