The best way is to use a python decorator. As an eg u can watch
jpscalleti code which he wrote as a good authentication system.
http://jpscaletti.com/webpy_auth/


On Sep 19, 1:20 pm, michael kapelko <[email protected]> wrote:
> Hi.
>
> I have lots of classes that look like this:
>
> class PAGE_NAME:
>     def GET(self, param):
>         if (session.get("login", None)):
>             i =web.input()
>             c = db()
>             return render.PAGE_NAME(session.login, c, i)
>         else:
>             raise web.seeother("/")
>
> If user is not logged it, it redirects to login page. Otherwise it
> displays necessary info.
> I have about 10 classes already and more to come. The code is all the
> same except for PAGE_NAME. Is there a way not to duplicate things?
>
> Also, for every such page I also must add the following to urls:
> "/PAGE_NAME(.*)", PAGE_NAME
> Is there a way to automate this as well?
>
> Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to