This issue has been reported in this thread:
https://groups.google.com/forum/#!searchin/web2py/IS_NOT_IN_DB/web2py/YNfreBJ2LYo/rEMOTVibHDEJ
... has it been solved, yet?
I defined the following table:
db.define_table('nodeKeyword',
Field('nodeID','reference
node',default='',requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('select a
value')),IS_NOT_IN_DB(db(db.nodeKeyword.word==request.vars.word),db.nodeKeyword.nodeID,error_message=T('combination
node and keyword already in
database'))],ondelete='CASCADE',notnull=True,writable=False,readable=False),
Field('word',length=128,default='',requires=[IS_IN_DB(db,'keyword.word','%(word)s',zero=T('select
a
value'))],ondelete='RESTRICT',notnull=True,widget=SQLFORM.widgets.options.widget,label='Trefwoord
* '),
migrate='nodeKeyword.table')
... which results in the following error:
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/web2py/gluon/restricted.py", line
209, in restricted
exec ccode in environment
File
"/Library/Python/2.6/site-packages/web2py/applications/init/models/10_tables_db.py"
<http://127.0.0.1:8000/admin/default/edit/init/models/10_tables_db.py>, line
134, in <module>
Field('nodeID','reference
node',default='',requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('select a
value')),IS_NOT_IN_DB(db(db.nodeKeyword.word==request.vars.word),db.nodeKeyword.nodeID,error_message=T('combination
node and keyword already in
database'))],ondelete='CASCADE',notnull=True,writable=False,readable=False),
File "/Library/Python/2.6/site-packages/web2py/gluon/dal.py", line 7099, in
__getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'nodeKeyword'
When I move the requires attribute outside the table definition:
db.nodeKeyword.nodeID.requires=[IS_IN_DB(db,'node.id','%(id)s',zero='select a
value'),IS_NOT_IN_DB(db(db.nodeKeyword.word==request.vars.word),db.nodeKeyword.nodeID,error_message='combination
node and keyword already in database')]
... the problem is solved, however, this is not compatible with lazy_tables, is
it?
Kind regards,
Annet.
--