Not sure what the problem is but this is definitively cause for trouble: T = current.T
In fact that is not thread safe. You cannot reference stuff in current outside a function or method. On Feb 27, 10:39 pm, IVINH <[email protected]> wrote: > HI, > > Please help me for this error: > > Traceback (most recent call last): > File "E:\web2py1994\gluon\restricted.py", line 204, in restricted > exec ccode in environment > File "E:/web2py1994/applications/app/controllers/plugin_attach.py" > <http://127.0.0.1:8000/admin/default/edit/app/controllers/plugin_attac...>, > line 29, in <module> > File "E:\web2py1994\gluon\globals.py", line 172, in <lambda> > self._caller = lambda f: f() > File "E:/web2py1994/applications/app/controllers/plugin_attach.py" > <http://127.0.0.1:8000/admin/default/edit/app/controllers/plugin_attac...>, > line 9, in index > a = define('object_attachment') > File "applications\app\modules\plugin_attach.py", line 28, in define > migrate=True) > File "E:\web2py1994\gluon\dal.py", line 5084, in define_table > common_filter=common_filter)) > File "E:\web2py1994\gluon\dal.py", line 5344, in __init__ > 'define_table argument is not a Field or Table: %s' % field > SyntaxError: define_table argument is not a Field or Table: <no table>.object > > My module: > > from gluon import current > from html import * > from dal import Field > import os > T = current.T > > def define(table_name): > db = current.globalenv['db'] > auth= current.globalenv['auth'] > if table_name not in db.tables: > db.define_table(table_name, > Field('object',writable=False,readable=False), > Field('object_id','integer',writable=False,readable=False), > Field('othet_object',writable=False,readable=False), > Field('other_id','integer',writable=False,readable=False), > Field('name',default=T('Attachment')), > Field('type'), > Field('extension'), > Field('file','upload',autodelete=True), > Field('created_by','integer',default=auth.user_id or > 1,writable=False,readable=False), > > Field('created_on','datetime',default=current.request.now,writable=False,re > adable=False), > migrate=True) > return db[table_name] > > my controller: > > from plugin_attach import define > def index(): > a = define('object_attachment') > return dict(f=a.fields)

