I have a web.py application where, if I authenticate user, then I set a 
session, and then use that session to determine if the user is logged in. The 
problem is that I'm breaking DRY by checking the status of the session within 
the definition of each class that corresponds to any URL that user might use. 
There is probably a better way to do this. Can anyone on the list offer some 
advice?

Thanks,
  John

class foo:        
    def GET(self):
        if (len(session.username) == 0):
            raise web.seeother('/login')
        foo = db.select('foo')
        return render.foo(foo)

class bar:        
    def GET(self):
        if (len(session.username) == 0):
            raise web.seeother('/login')
        return render.bar()

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