On Sunday, June 12, 2011 "Franck" <[email protected]> wrote:
> I suppose you could use an "application processor" : basically it
> could be written once and check the user before each request
> http://webpy.org/cookbook/application_processors

Just wanted to say this did the job very nicely. Thanks. 

  John

def authenticated():
    if (not (web.ctx.path == '/login')):
        if (len(session.username) == 0):
            raise web.seeother('/login')

def session_hook():
    web.ctx.session = session
    web.template.Template.globals['session'] = session

    application = web.application(urls, globals())
    session = web.session.Session(application,
                                  web.session.DiskStore('sessions'),
                                  initializer={'username': ''})
    application.add_processor(web.loadhook(session_hook))
    application.add_processor(web.loadhook(authenticated))

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