Provides the BaseController class for subclassing.
"""
+from pylons import session, tmpl_context as c
from pylons.controllers import WSGIController
from pylons.templating import render_mako as render
+from floof import model
from floof.model import meta
class BaseController(WSGIController):
+ def __before__(self, action, **params):
+ # Fetch current user object
+ try:
+ c.user = meta.Session.query(model.User).get(session['user_id'])
+ except:
+ pass
+
def __call__(self, environ, start_response):
"""Invoke the Controller"""
# WSGIController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
- try:
- return WSGIController.__call__(self, environ, start_response)
- finally:
- meta.Session.remove()
+ return WSGIController.__call__(self, environ, start_response)