Added OpenID registration and login.
[zzz-floof.git] / floof / lib / base.py
1 """The base Controller API
2
3 Provides the BaseController class for subclassing.
4 """
5 from pylons import session, tmpl_context as c
6 from pylons.controllers import WSGIController
7 from pylons.templating import render_mako as render
8
9 from floof import model
10 from floof.model import meta
11
12 class BaseController(WSGIController):
13
14 def __before__(self, action, **params):
15 # Fetch current user object
16 try:
17 c.user = meta.Session.query(model.User).get(session['user_id'])
18 except:
19 pass
20
21 def __call__(self, environ, start_response):
22 """Invoke the Controller"""
23 # WSGIController.__call__ dispatches to the Controller method
24 # the request is routed to. This routing information is
25 # available in environ['pylons.routes_dict']
26 try:
27 return WSGIController.__call__(self, environ, start_response)
28 finally:
29 meta.Session.remove()