class MyStrangeRequirement(object):
def __init__(self,s='R',error_message='forgot the R?'):
self.s=s
self.error_message = error_message
def __call__(self,value):
if not (value and value.endswith(self.s)):
return (value, self.error_message)
return value[:-len(self.s)]
db.auth_user.username.requires.insert(0, MyStrangeRequirement())
On Thursday, 29 March 2012 13:09:44 UTC-5, Detectedstealth wrote:
>
> Hi,
>
> I need to be able to add a character to the end of a username that can be
> changed by us. This character is not actually stored in the database for
> the username however it must be entered for the username to validate.
>
> For example:
> username: 0000012 -> is stored in the database
>
> Login with: 0000012 would fail
> Login with: 0000012R would succeed
>
> This is a business requirement so even if I don't like this idea I still
> need to program it. How to make this work with the current login system? Is
> there a way to capture the form submit before the handler actually
> processes it, pull the last character if it is valid pass the username
> without the character to the real login validator?
>
> --
> --
> Regards,
> Bruce Wade
> http://ca.linkedin.com/in/brucelwade
> http://www.wadecybertech.com
> http://www.warplydesigned.com
> http://www.fitnessfriendsfinder.com
>