That is by design. model is not a module. this of
db.define_table('whetever',Field('ts','datetime',default=request.now))
request.now is the date of the request. For this default to be properly set
this MUST run at every request.
This is the price you pay for the simple web2py syntax. If you don't want
pay this price you can use web2py as any other ORM. You put everything in a
module , you import the module, etc.
On Wednesday, 15 August 2012 17:53:08 UTC-5, Derek wrote:
>
> Yes, I tried it on the model, it is true on every request. I don't
> understand why.
>
> On Tuesday, August 14, 2012 3:07:43 PM UTC-7, Anthony wrote:
>>
>> Where would you put that? If in a model or controller, won't the
>> condition be true on every request?
>>
>> Anthony
>>
>> On Tuesday, August 14, 2012 4:44:24 PM UTC-4, Derek wrote:
>>>
>>> Would it not be possible to do something like this:
>>>
>>> if 'db' not in dir():
>>> db = DAL(...)
>>>
>>>
>>> On Monday, August 13, 2012 6:43:34 PM UTC-7, rochacbruno wrote:
>>>>
>>>>
>>>> Thinking again...
>>>>
>>>> It could be better if "define_my_tables" run once on the very first
>>>> request and table keeps defined forever from there....
>>>>
>>>
--