If you don't want to do an Ajax request on every page to fetch the login
form, you might consider either (a) retrieving the form via Ajax only when
the user clicks on a link/button, or (b) including the form directly in the
layout (which will require changing the "action" attribute so the form
posts to the login action):
{{=auth.login().update(_action=auth.settings.login_url) if not auth.user
else ''}}
If you include the above in layout.html, it will show the login form if the
user is not logged in, and when submitted, the form will post to the login
action.
Anthony
On Monday, June 3, 2013 4:35:50 AM UTC-4, lesssugar wrote:
>
> All clear. Thank you.
>
> On Monday, June 3, 2013 5:34:55 AM UTC+2, Massimo Di Pierro wrote:
>>
>> On Sunday, 2 June 2013 17:15:55 UTC-5, lesssugar wrote:
>>
>>> OK, this might be a silly one.
>>>
>>> My app uses one main view (layout.html), which is extended by every
>>> other one.
>>> layout.html has a login form included, created in default.py controller
>>> (the form is supposed to be at hand until user signs in).
>>>
>>> Now, whenever I use any other controller, I get an error saying that
>>> name "login_form" is not defined.
>>> Example: I'm on default/index page (the login form's included). I click
>>> on a link to go to [other controller]/index (which of course extends
>>> layout.html). The page throws the mentioned error.
>>>
>>> Do all the functions in controllers other than default.py need to return
>>> "login_form" to get it working?
>>>
>>
>> Yes. web2py is a push framework, like Rails and Django, not a pull
>> framework.
>> You have the option of defining the login form in a model (nor
>> recommended) or handle the login form via ajax.
>>
>>
>>> I believe not but I'm not sure how to do it properly.
>>>
>>>
--
---
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.