On Wednesday, September 9, 2015 at 8:21:41 AM UTC-4, desta wrote:
>
> Thank you.
>
> I am trying to follow the procedure. So when the login form is submitted,
> I guess line 1609 is called (?)
> https://github.com/web2py/web2py/blob/master/gluon/tools.py#L1609.
>
> Following the getattr, I can't seem to find where it validates and
> redirects. Could you please enlighten me?
>
The line in question is:
return getattr(self, args[0])()
If args[0] is "login", then getattr(self, args[0]) will refer to the
gluon.tools.Auth.login method. The additional set of parentheses at the end
of the line indicate that method is actually being called, and its result
is being returned. So, ultimately, the login method is simply being called,
which you can find here:
https://github.com/web2py/web2py/blob/master/gluon/tools.py#L2494
Anthony
> Thanks
>
> On Wednesday, September 9, 2015 at 1:33:46 PM UTC+3, Leonel Câmara wrote:
>>
>> auth is an instance of Auth that you have defined in your model. Auth
>> happens to have a __call__ method so auth will be callable like a function.
>>
>> When called auth uses the first argument (request.args(0)) to get the
>> correct user function (login, register, etc) from Auth using getattr and
>> returns its result, these return similar enough results (mostly just a
>> form) that they can all use the same view in default/user.html.
>>
>> If you want to understand more see:
>> https://github.com/web2py/web2py/blob/master/gluon/tools.py#L1584
>>
>
--
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.