Create a IS_NOT_EMAIL() validator :
class IS_NOT_EMAIL:
def __init__(self, error_message='You can\'t use email as username'):
self.e = error_message
def __call__(self, value):
if not IS_EMAIL()(value)[1]:
return (value, self.e)
return (value, None)
Base on this!!
I wonder why we don't set flag on validators for "reverse validation" when
apply, for instance : IS_EMAIL(..., *complement=True*) will return an error
if input is email... This is use in python petl project :
http://petl.readthedocs.org/en/latest/
Thanks.
Richard
On Sun, Jun 2, 2013 at 9:20 AM, Massimo Di Pierro <
[email protected]> wrote:
> Do you need the commented lines?
>
> #request.vars.email = request.vars.username
> request.post_vars.email = request.vars.email
> #request.vars.username = None
> request.post_vars.username = None
>
> On Saturday, 1 June 2013 21:27:05 UTC-5, Gustavo Souza wrote:
>>
>> Worked for me the following code:
>>
>> if 'login' in request.args:
>> auth.settings.login_userfield = 'username'
>> if request.vars.username and not IS_EMAIL()(request.vars.**
>> username)[1]:
>> auth.settings.login_userfield = 'email'
>> request.vars.email = request.vars.username
>> request.post_vars.email = request.vars.email
>> request.vars.username = None
>> request.post_vars.username = None
>>
>> return dict(form=auth.login())
>>
>> Em sexta-feira, 9 de dezembro de 2011 10h22min57s UTC-2, Francisco Costa
>> escreveu:
>>>
>>> lots of users on login form submit their email instead of the
>>> username..
>>>
>>> it seems that auth.define_tables(username=**True) forces username login
>>> but it is possible to have both?
>>>
>> --
>
> ---
> 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/groups/opt_out.
>
>
>
--
---
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/groups/opt_out.