response.flash only lasts for the current request, but immediately after 
setting it, you do a redirect, which results in a new request being sent 
from the browser. In such a case, you should instead set session.flash, 
which will be copied into response.flash after the redirect.

Also, note that Python has elif, which you should use instead of else: if.

Anthony

On Thursday, November 5, 2015 at 11:46:12 AM UTC-5, Alessio Varalta wrote:
>
> def user():
>     """
>     exposes:
>     http://..../[app]/default/user/login
>     http://..../[app]/default/user/logout
>     http://..../[app]/default/user/register
>     http://..../[app]/default/user/profile
>     http://..../[app]/default/user/retrieve_password
>     http://..../[app]/default/user/change_password
>     http://..../[app]/default/user/manage_users (requires membership in
>     http://..../[app]/default/user/bulk_register
>     use @auth.requires_login()
>         @auth.requires_membership('group name')
>         @auth.requires_permission('read','table name',record_id)
>     to decorate functions that need access control
>     """
>     if request.args(0)=='register':
>         redirect(URL('default','register'))
>     else:
>         if request.args(0)=='login':
>             if (session.message_registration=="Vero"):
>                 response.flash="La tua richiesta di registrazione e' stata 
> inviata al Consorzio. Aspetta un email di conferma prima di effettuare il 
> tuo primo login";
>             redirect(URL('default','login'))
>     return dict(form=auth())
>
> def login():
>     form=auth.login()
>     return dict(form=form)
>
> Is corret? I have a problem with the error message because i don't see the 
> error but only the response.flash login incorrect..so I use
>
> if form.accepts(request,session):
>         response.flash = 'form accepted'
>     elif form.errors:
>         response.flash = 'form has errors'
>     else:
>         response.flash = 'please fill the form'
>
> but I have a problem that i don't enter in 
> if form.accepts(request,session):
>

-- 
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