you really have to work on packaging examples app if you want someone to 
try to reproduce and identify the bugs... We can't possibly figure out all 
the intricacies of your models and your underlying data structure from a 
few lines.

PS: the only thin I can tell you for sure is that db.insert(something) 
doesn't call the validators, that are meant to be used only in forms. If 
you want your validators called you must use 
db.validate_and_insert(something) . Moreover, if your validator is based on 
something that is available only as request.vars.something, if 
request.vars.something isn't there you can't possibly hope for the 
validator to act like when called on forms in your db.validate_and_insert .

On Friday, October 26, 2012 8:39:34 AM UTC+2, Annet wrote:
>
> On a tabel tie:
>
> db.define_table('tie',
>     Field('hubID','reference node',**isnode),
>     Field('nodeID','reference 
> node',default='',ondelete='CASCADE',notnull=True),
>     ...
>     on_define=set_requirement,
>     migrate=False)
>
>
> I defined the following validator:
>
> def set_requirement(tie): 
> tie.nodeID.requires=[IS_IN_DB(db,'node.id','%(id)s',zero=T('select 
> a 
> value')),IS_NOT_IN_DB(db(db.tie.hubID==request.vars.hubID),'tie.nodeID',error_message=T('combination
>  
> hub and node already in database'))]
>
>
> Again in appadmin when I enter hubID 11 and nodeID 3 the second time I get 
> the error_message, however, in form=crud.update(db.tie) and 
> form=SQLFORM.factory(db.tie,record=row) and  db.tie.insert(hubID=id,nodeID=
> row.id) this combination is entered without this being prevented by the 
> validator.
>
> I defined my validators this way to make use of lazy_table=True. Does the 
> fact that validators defined this way are ignored in the controller mean 
> that I have to revert to my previous validator definitions and that I 
> cannot make use of lazy_tables? (I am still working in web2py 2.0.9, maybe 
> this issue has been resolved in 2.2.x)
>
>
> Kind regards,
>
> Annet.
>

-- 



Reply via email to