Fran, the code above was just an example. You have to adapt the validator parameters to your own model, i.e. you don't have a 'gis' table.
On Dec 3, 2:50 am, Fran <[EMAIL PROTECTED]> wrote: > > Fran, the following validator seems to work as per your needs: > > This looks really nice - many thanks! > Also looks generic enough to be worth including in Web2Py core > (Massimo?) > [Although I'm wondering whether it could still be worth adding the > ability to package custom validators within an application to keep > them portable. I guess the modules directory could be used for this so > having a 'validators_custom.py' in that folder which gets hooked in > sounds useful to me...] > > However if I put this into my db.py it fails: > > Traceback (most recent call last): > File "C:\Bin\web2py\gluon\restricted.py", line 62, in restricted > exec ccode in environment > File "C:\Bin\web2py\applications\sahana/models/db.py", line 107, in > <module> > db.gis.key.requires=THIS_NOT_IN_DB(db > (db.gis.service==request.vars.service),'gis.service',request.vars.service,'service > already in use') > File "C:\Bin\web2py\gluon\validators.py", line 763, in __init__ > field=self.dbset._db[tablename][fieldname] > NameError: global name 'tablename' is not defined > > I've looked into the code & the only reason that I can think this > would be the case is that request.vars.service is blank. > I've tried to test this by appending a '?service=google' to the end of > the URL but it still fails. > I also tried moving this advanced validation to the controller or even > view without luck... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---