Hello,

I am new in python and web2py also.

I tryed to create a custom auth because I have a project and it is needing 
a lot validation on user creation action.

I need to validate the birthdate and it is needing to be >= 18 from today. 
So, I tried to create a requires like:

custom_auth_table.dt_b.requires = lambda custom_auth_table.dt_nasc: True if 
(hoje-int(str(custom_auth_table.t_b)[4:])) >= 18 else False

but I having a error:

Traceback (most recent call last):
  File "/home/87k/web2py/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/home/87k/web2py/applications/87k/controllers/default.py" 
<https://87k.pythonanywhere.com/admin/edit/87k/controllers/default.py>, line 
77, in <module>
  File "/home/87k/web2py/gluon/globals.py", line 417, in <lambda>
    self._caller = lambda f: f()
  File "/home/87k/web2py/applications/87k/controllers/default.py" 
<https://87k.pythonanywhere.com/admin/edit/87k/controllers/default.py>, line 
41, in user
    return dict(form=auth())
  File "/home/87k/web2py/gluon/tools.py", line 1941, in __call__
    return getattr(self, args[0])()
  File "/home/87k/web2py/gluon/tools.py", line 3351, in register
    hideerror=self.settings.hideerror):
  File "/home/87k/web2py/gluon/sqlhtml.py", line 1529, in accepts
    **kwargs
  File "/home/87k/web2py/gluon/html.py", line 2122, in accepts
    status = self._traverse(status, hideerror)
  File "/home/87k/web2py/gluon/html.py", line 889, in _traverse
    newstatus = c._traverse(status, hideerror) and newstatus
  File "/home/87k/web2py/gluon/html.py", line 889, in _traverse
    newstatus = c._traverse(status, hideerror) and newstatus
  File "/home/87k/web2py/gluon/html.py", line 889, in _traverse
    newstatus = c._traverse(status, hideerror) and newstatus
  File "/home/87k/web2py/gluon/html.py", line 889, in _traverse
    newstatus = c._traverse(status, hideerror) and newstatus
  File "/home/87k/web2py/gluon/html.py", line 896, in _traverse
    newstatus = self._validate()
  File "/home/87k/web2py/gluon/html.py", line 1867, in _validate
    raise Exception(msg)
Exception: Validation error, field:dt_nasc <function <lambda> at 0x7f8d7e494668>


I need how to do these requires because I need to perform another validation, 
there is a possibility the unique user has 5 accounts and I will use a specif 
document number, I will need to create another funcition to check 5 "counts" on 
auth_user table.

I believe learning the first problem, I will be able to do the second 
validation.

Thank you in advance.

Best regards

André

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to