[web2py] Re: nested reference fields in IS_IN_DB validator

2015-12-16 Thread Pierre-Antoine Roiron
Here's what I had in mind, if of any interest. This function does not work (and it's a simplified one that dosn't take into account the multiple=True in db.customer.guitar_ref). I'm not sure why it dosn't work. I think it's because I call a function in the first arg of IS_IN_DB. If someone coul

[web2py] Re: nested reference fields in IS_IN_DB validator

2015-12-15 Thread Pierre-Antoine Roiron
OK, that's the problem discussed in the "Validators with dependencies" paragraph of the book. It took me some time to realize that. From what I've read from other developers, it's not possible to solve this in the model if I understand well, even if the book says so. I'll solve this by adding th

[web2py] Re: nested reference fields in IS_IN_DB validator

2015-12-15 Thread Pierre-Antoine Roiron
This is my latest best try, but it still returns a syntax error when executing (not when compiling) : db.define_table('guitar', Field('brand',type='string')) db.define_table('customer', Field('name',type='string'), F

[web2py] Re: nested reference fields in IS_IN_DB validator

2015-12-15 Thread Pierre-Antoine Roiron
I want to write something like that, but I know it's not correct because it doesn't provide the link between the invoice._id considered and c_id : c_id=db.invoice.customer_ref g_id=db.customer[c_id].guitar_ref db.invoice.guitar_ref.requires=IS_IN_DB(db(db.guitar._id==g_id),'guitar.id') -- Resour