NameError: name 'now' is not defined

131 views
Skip to first unread message

Sciurus vulgaris

unread,
Feb 8, 2012, 7:49:51 AM2/8/12
to web...@googlegroups.com
Hello,

i got an exception when using the sample code for storring the sessions in a database. I used the sample code from http://www.web2py.com/book/default/chapter/04#session

Model:
...
db.define_table('web2py_session',
    Field('locked', 'boolean', default=False),
    Field('client_ip'),
    Field('created_datetime', 'datetime', default=now),
    Field('modified_datetime', 'datetime'),
    Field('unique_key'),
    Field('session_data', 'text'))
...

Exception:
Traceback (most recent call last):
  File "/home/geht/euch/nichts/an/web2py/gluon/restricted.py", line 192, in restricted
    exec ccode in environment
  File "/home/geht/euch/nichts/an/web2py/applications/moepse/models/default.py", line 30, in <module>
Field('created_datetime', 'datetime', default=now), NameError: name 'now' is not defined

Kind Regards,
Sciurus vulgaris

Anthony

unread,
Feb 8, 2012, 8:50:12 AM2/8/12
to web...@googlegroups.com
Should probably be request.now.

Anthony

Sciurus vulgaris

unread,
Feb 8, 2012, 8:50:56 AM2/8/12
to web...@googlegroups.com
Solved, web2py automatic generates this table when using session.connect.

Kind Regards,

Sciurus vulgaris
Reply all
Reply to author
Forward
0 new messages