Does it work if you do?

db.nodeRelatedName.relatedID.requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('select
 
a 
value')),IS_NOT_IN_DB(db(db.nodeRelatedName.nodeID==request.vars.nodeID),'nodeRelatedName.relatedID',error_message=T('combination
 
node and related name already in database'))]



On Saturday, 13 October 2012 03:19:24 UTC-5, Annet wrote:
>
> In db.py I define the following table:
>
> def set_requirement(nodeRelatedName): 
> nodeRelatedName.relatedID.requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('select
>  
> a 
> value')),IS_NOT_IN_DB(db(db.nodeRelatedName.nodeID==request.vars.nodeID),'nodeRelatedName.relatedID',error_message=T('combination
>  
> node and related name already in database'))]
>
> db.define_table('nodeRelatedName',
>     Field('nodeID','reference node',**isnode),
>     Field('relatedID','reference 
> node',default='',ondelete='CASCADE',notnull=True),
>     
> Field('insequence',type='integer',default=0,writable=False,readable=False),
>     Field('createdOn',**attributes),
>     Field('modifiedOn',update=request.now,**attributes),
>     on_define=set_requirement,
>     migrate=False)
>
> The problem is that the validator doesn't work, I should prevent users 
> from adding the same combination of nodeID and relatedID twice or more, but 
> it doesn't. What's the correct syntax to implement this?
>
> Kind regards,
>
> Annet
>

-- 



Reply via email to