>
> db.poc.Name.requires = [IS_UPPER 
> <https://xortho.it/examples/global/vars/IS_UPPER>(), CRYPT 
> <https://xortho.it/examples/global/vars/CRYPT>(),
>                         IS_NOT_IN_DB(db(db.poc.Birthday == 
> request.vars.Birthday), 'poc.Name')]
>
>
>
> I've tried but this doesn't work properly and adds duplicated data. I 
> figured out  that is probably because I'm using CRYPT() and I get a 
> LazyCrypt Object but IS_NOT_IN_DB expects a string
>

Try:

db.poc.Name.requires = [IS_UPPER 
<https://xortho.it/examples/global/vars/IS_UPPER>(), lambda v: (str(CRYPT 
<https://xortho.it/examples/global/vars/CRYPT>()(v)[0]), None),
                        IS_NOT_IN_DB(db(db.poc.Birthday == 
request.vars.Birthday), 'poc.Name')]

 

> Where can'I find the source code for _before_insert?
>

https://github.com/web2py/pydal/blob/master/pydal/objects.py#L729 

A few additional tips:
>
>
>    - form.process() accepts a "message_onsuccess" argument, so you can 
>    use that instead of checking if the form is accepted and explicitly 
> setting 
>    response.flash.
>    
> Tried and this prevent  "record added" message but I'm still unable to 
> show a duplicate error message.
>

That wasn't intended as a solution to this particular problem, just a tip 
for when you do need to set an onsuccess flash message.

Anthony

>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to