[albatross-users] next bit of confused insight
Gregory Bond
gnb at itga.com.au
Fri Sep 26 10:54:32 EST 2003
OK, the next problem here is you have 2 app objects.
One is in edit_config.py and has the edit_config page registered.
One is in go_login(), which doesn't have this page registered.
Calling set_page('edit_config') inside the login page is using the login app
object, which doesn't have this page registered, hence the error.
There should be no need for a separate app object in the login function.
Were I to attack the problem of "make sure I have valid auth at all times", I'd
do something like this (bearing in mind I use page objects, not page modules,
and file-based server-side sessions for non-Random apps):
- Create a base class for all my page objects (I do this anyway so I can put
application-wide nav bars etc in)
- This base class would have a page_process function like this
def page_process(self, ctx):
if not hasattr(ctx.locals, '_auth'):
ctx.set_page('login')
return
if not valid_auth(ctx.locals._auth):
ctx.set_page('login_expired')
return
self.sub_page_process(ctx)
- 2 new pages, for initial login and for handling stale/expired auth
credentials. These would set the ctx.locals._auth member into the session
state and then set_page() to the main application page. These objects
would NOT be a subclass of the above base!
- All other pages subclass the page base and provide a sub_page_process() to
do the actual navigation.
This should ensure that the auth is checked and valid before any action is
taken anywhere in the application.
More information about the Albatross-users
mailing list