Have you read the chapter on access control: http://web2py.com/book/default/chapter/08? The Auth system should be able to handle this kind of thing for you. You can use @auth decorators on your actions to require login, group membership, or other arbitrary conditions. If the user is not logged in, they will be redirected to the login page automatically, and redirected back to the originally requested page after login.
Anthony On Wednesday, October 12, 2011 2:32:43 AM UTC-4, miroslavgojic wrote: > > I have login form (I can regiser, or log in, ...) but how to apply this > login to some site page. > > from login.form I can get user.name or user.id > > I need something like if to check this > > {{ if user.name == 'user':}} > go to some page or some content > {{else:}} > open login form > {{pass}} > > this is what is on my mind but is this only options or already is something > implemented by default. > > - - Miroslav Gojic - - > > > On Tue, Oct 11, 2011 at 00:10, Massimo Di Pierro <massimo....@gmail.com>wrote: > >> In fact this >> {{if {{=request.function}} == index:}} >> is wrong because web2py would look for the first {{ and the first }} >> and try interpret the code in between as python. By >> >> "if {{=request.function" is not valid python. >> >> You want: >> >> {{if request.function == 'index':}} >> >> >> On Oct 10, 4:28 pm, Anthony <abas...@gmail.com> wrote: >> > > {{if {{=request.function}} == index:}} >> > >> > Yes, once you're inside a {{}}, you can write any Python and refer to >> any >> > global (or local) variables -- so no need to nest another {{=}} in >> there. >> > >