X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/e080215f07b8153ef01d6c840a4ba3a4bfc2d770..a058598f1ee11c60f9718d0ec677df1424be79c3:/floof/lib/base.py?ds=sidebyside diff --git a/floof/lib/base.py b/floof/lib/base.py index fd6ee47..af47069 100644 --- a/floof/lib/base.py +++ b/floof/lib/base.py @@ -2,19 +2,25 @@ 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)