Or better yet, store the validator object in a variable and use that:

isnotindb=IS_NOT_IN_DB(...)
db.company.CoC_number.requires=isnotindb

and in the action:

isnotindb.set_self_id(company[0].id)

then it does not matter if the field uses more validators, since you
could for example do:

db.company.CoC_number.requires=[IS_NOT_EMPTY(),isnotindb]

and the statement with set_self_id would still work.


On Mar 9, 5:35 am, DenesL <denes1...@yahoo.ca> wrote:
> Hi Annet,
>
> the requires for the field is now a list of validators for some
> reason.
> You have to use the set_self_id only on the IS_NOT_IN_DB portion of
> the requires.
>
> Did you change the requires?.
> If not, then it is probably just a one member list so you can do
>
> db.company.CoC_number.requires[0].set_self_id(company[0].id)
>
> On Mar 9, 4:03 am, annet <annet.verm...@gmail.com> wrote:
>
> > Hi Denes,
>
> > Thanks for your reply. I tried:
>
> > >           # this is undocumented
> > >           db.company.CoC_number.requires.set_self_id(company[0].id)
>
> > > >         form.vars.name=company[0].name
> > > >         form.vars.CoC_number=company[0].CoC_number
> > > >         form.vars.subdossiernumber=company[0].subdossiernumber
> > > >         ...
> > > >         if form.accepts(request.vars,session):
>
> > ... and got this error ticket:
>
> > Traceback (most recent call last):
> >   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> > restricted.py", line 188, in restricted
> >     exec ccode in environment
> >   File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
> > cms/controllers/myadmin.py", line 262, in <module>
> >   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> > globals.py", line 96, in <lambda>
> >     self._caller = lambda f: f()
> >   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> > tools.py", line 2237, in f
> >     return action(*a, **b)
> >   File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
> > cms/controllers/myadmin.py", line 180, in update
> >     db.company.CoC_number.requires.set_self_id(company[0].id)
> > AttributeError: 'list' object has no attribute 'set_self_id'
>
> > ... do you know why?
>
> > Kind regards,
>
> > Annet.
>
>

Reply via email to