projects
/
zzz-floof.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make User.name unique.
[zzz-floof.git]
/
floof
/
lib
/
base.py
diff --git
a/floof/lib/base.py
b/floof/lib/base.py
index
cb7c746
..
b42d2be
100644
(file)
--- a/
floof/lib/base.py
+++ b/
floof/lib/base.py
@@
-3,17
+3,20
@@
Provides the BaseController class for subclassing.
"""
from pylons.controllers import WSGIController
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.templating import render_mako as render
-from pylons import config
-from
floof import model
+from pylons import config
, request, session, tmpl_context as c
+from
routes import request_config
-from
pylons import session, tmpl_context as c
+from
floof import model
from floof.model.users import User
class BaseController(WSGIController):
# NOTE: This could have been implemented as a middleware =]
from floof.model.users import User
class BaseController(WSGIController):
# NOTE: This could have been implemented as a middleware =]
- def __before__(self, action, **params):
+ def __before__(self):
+ c.route = request_config().mapper_dict
+
# Fetch current user object
try:
c.user = User.query.get(session['user_id'])
# Fetch current user object
try:
c.user = User.query.get(session['user_id'])
@@
-32,3
+35,11
@@
class BaseController(WSGIController):
return WSGIController.__call__(self, environ, start_response)
finally:
model.Session.remove()
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)