On Friday, November 9, 2018 at 5:31:18 AM UTC-8, Ben Duncan wrote:
>
> Ok, I'm checking my DAL layouts with s simply pydal test program and I've
> run into this:
>
> [postgres@su-postgres-ben-3 mec_layouts]$ ./pydaltest2.py
> Traceback (most recent call last):
> File "./pydaltest2.py", line 289, in <module>
> Field('created_datetime', type='datetime', default=request.now),
> NameError: name 'request' is not defined
>
The variable request is a web2py global, but when you're running pydal
standalone you don't have the web2py globals.
You might try
import datetime
if "request" not in globals():
request["now"] = datetime.datetime.now()
before your table defines. (Or, if you always be running standalone, just
change the default.)
/dps
The top of my program looks like :
>
> import os, sys, string, copy, time
> import getopt
> from types import *
>
>
> from pydal import DAL , Field
> db = DAL("postgres://postgres:postgres@localhost:7103/ac03303_live",
> pool_size=10, migrate_enabled=False, fake_migrate_all=True )
>
> db.define_table .......
> db.define_table ....... (etc)
> db.define_table('cookie_s',
> Field('company_number', type='reference company', ondelete='CASCADE'),
> Field('prid', type='integer'),
> Field('value', type='string', length=255),
> Field('java_ready', type='boolean'),
> Field('content', type='string', length=255),
> Field('created_datetime', type='datetime', default=request.now),
> Field('expire', type='datetime'),
> Field('machine_id', type='string', length=255),
> Field('browser_session', type='integer'),
> Field('server_session', type='integer'),
> primarykey=['company_number','prid'],
> migrate=False)
>
> It's blowing up on the
> Field('created_datetime', type='datetime', default=request.now),
>
> What Am I doing wrong ?
>
> Thanks ..
>
>
>
> *Ben Duncan*
> DBA / Chief Software Architect
> Mississippi State Supreme Court
> Electronic Filing Division
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.