views:

142

answers:

1

Hi

I'm designing a site on google app engine and i think about a way of authenticating user wihtout redirecting them to google.

My structure of website in yaml is like:

- url: /
  script: /main.py
- url: /some_page
  script: some_page.py

so every page has it own mapping in yaml. Assuming that some pages will be accesible only to logged in users and others to all users, how i can authenticate them across pages?

I'm thinking to create a module that will check DB and set cookies, and import it on each page.

Are there other or better ways of doing this?

+1  A: 

The method you described will work. You may want to checkout an existing session library, like beaker.

Having every page in a different handler is a rather unusual approach, though. It's far more common to have a single handler for your app, which uses a WSGI router/dispatcher to load the appropriate handler class. This avoids a lot of replication of boilerplate - especially once you add a session library into the mix.

Nick Johnson