Hi,
if you simply cut & paste the following code in a model of a generic app
maybe you'll get a table called layers_wms in your database without any
problem but if you try to insert a record in it you'll get the traceback
reported after.
Can you help me to understand why I get this traceback?
from gluon.storage import Storage
class OpenLayers(object):
basic = db.Table(db, '_basic_',
Field('name', required=True, unique=True, label=T('Name'),
comment=T('Layer Name'))
)
WMS = Storage(dict(
options = db.Table(db, '_options_',
Field('layers', required=True, unique=True,
label=T('workspace:name'), comment=T('Layer\'s workspace and name')),
# Field('projection', miscdb.locations, default=1,
required=True, notnull=True,
# requires=IS_IN_DB(miscdb, 'locations.id', '%(name)s')),
Field('format', default='image/png'),
Field('transparent', 'boolean', default=True),
Field('opacity', 'decimal(4,2)', default=1.0),
Field('visibility', 'boolean', default=True,
# requires=JS_BOOLEAN(),
widget=SQLFORM.widgets.boolean.widget
),
))
)
WMS['Layer'] = db.Table(db, '_wms_',
basic,
Field('url', label=T('Url'), comment=T(''), requires=IS_URL()),
WMS.options,
# {Boolean} Default is true for WMS layer
Field('isBaseLayer', 'boolean', default=False)
# {Boolean} Should the BBOX commas be encoded?
# Field('encodeBBOX'),
# {Boolean} If true, the image format will not be
automagicaly switched
# from image/jpeg to image/png or image/gif when using
TRANSPARENT=TRUE.
# Field('noMagic'),
)
db.define_table('layers_wms',
OpenLayers.WMS.Layer
)
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
Traceback(most recent call last):
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/restricted.py",line192,inrestricted
execccodeinenvironment
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
<http://localhost:8000/admin/default/edit/geo_dev/controllers/appadmin.py>,line410,in<module>
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/globals.py",line145,in<lambda>
self._caller=lambdaf:f()
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/applications/geo_dev/controllers/appadmin.py"
<http://localhost:8000/admin/default/edit/geo_dev/controllers/appadmin.py>,line127,ininsert
ifform.accepts(request.vars,session):
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/sqlhtml.py",line1043,inaccepts
hideerror=hideerror,
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1765,inaccepts
status=self._traverse(status,hideerror)
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line726,in_traverse
newstatus=c._traverse(status,hideerror)andnewstatus
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line733,in_traverse
newstatus=self._validate()
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/html.py",line1538,in_validate
(value,errors) =validator(value)
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/validators.py",line515,in__call__
field=self.dbset.db[tablename][fieldname]
File"/home/manuele/Dropbox/sviluppo/web2py-1.97.1/gluon/dal.py",line4325,in__getitem__
returndict.__getitem__(self,str(key))
KeyError:'_basic_'