It is probably useful to repeat this from the book, for the community: When you think of dataflow, from your client to your persistent store:
".requires=..." is enforced at the level of forms; "required=True" is enforced by the DAL (prior to insert); "notnull", "unique", and "ondelete" is enforced at the db server. On Sat, Jul 18, 2009 at 6:47 PM, ionel <[email protected]> wrote: > > Thanks. It make sense. > > On Jul 18, 3:16 pm, Yarko Tymciurak <[email protected]> wrote: > > On Sat, Jul 18, 2009 at 1:00 PM, ionel <[email protected]> wrote: > > > > > Hello, > > > I have the following situation: > > > > > Model: > > > > > db.define_table('country', db.Field('country', 'string', length=50)) > > > > > db.define_table(region', > > > db.Field('name', 'string', length=50), > > > db.Field('country', 'reference country') > > > ) > > > db.region.country.requires=IS_IN_DB(db, 'country.id', '%(country)s', > > > orderby=db.country.country) > > > > > Controller: > > > > > def test(): > > > country_id = db.country.insert(country=-1, region="Same > > > region") > > > > > Problem: > > > > > There is no country.id = -1 in the country table, but INSERT is > > > executed despite the validator > > > > db.region.country.requires is a validator; it is not a constraint on DAL; > it > > is on SQLForm; > > > > > > > > > db.region.country.requires=IS_IN_DB(db, 'country.id', '%(country)s', > > > orderby=db.country.country) > > > > > Is this an expected behavior? > > > > > Thanks. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

