X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/a058598f1ee11c60f9718d0ec677df1424be79c3..cb1976ef371904b45d7961212cd87595a9486284:/floof/lib/base.py?ds=inline diff --git a/floof/lib/base.py b/floof/lib/base.py index af47069..169493c 100644 --- a/floof/lib/base.py +++ b/floof/lib/base.py @@ -2,19 +2,23 @@ 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 pylons import config, session, tmpl_context as c +from routes import request_config from floof import model -from floof.model import meta +from floof.model.users import User class BaseController(WSGIController): - def __before__(self, action, **params): + # NOTE: This could have been implemented as a middleware =] + def __before__(self): + c.route = request_config().mapper_dict + # Fetch current user object try: - c.user = meta.Session.query(model.User).get(session['user_id']) + c.user = User.query.get(session['user_id']) except: pass @@ -23,4 +27,10 @@ class BaseController(WSGIController): # WSGIController.__call__ dispatches to the Controller method # the request is routed to. This routing information is # available in environ['pylons.routes_dict'] - return WSGIController.__call__(self, environ, start_response) + + # Insert any code to be run per request here. + + try: + return WSGIController.__call__(self, environ, start_response) + finally: + model.Session.remove()