Provides the BaseController class for subclassing.
"""
from pylons.controllers import WSGIController
+from pylons.controllers.util import abort, redirect
from pylons.templating import render_mako as render
-from pylons import config, session, tmpl_context as c
+from pylons import config, request, session, tmpl_context as c
from routes import request_config
from floof import model
try:
c.user = User.query.get(session['user_id'])
except:
+ c.user = None
pass
def __call__(self, environ, start_response):
return WSGIController.__call__(self, environ, start_response)
finally:
model.Session.remove()
+
+
+ def redirect_to_referrer(self):
+ """Performs a redirect_to to wherever we came from. Used for stuff
+ like logging in.
+ """
+ referrer = request.headers.get('REFERER', '/')
+ redirect(referrer, code=302)