projects
/
zzz-floof.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a bunch of NOT NULLs.
[zzz-floof.git]
/
floof
/
lib
/
base.py
diff --git
a/floof/lib/base.py
b/floof/lib/base.py
index
d2756ba
..
c93803b
100644
(file)
--- a/
floof/lib/base.py
+++ b/
floof/lib/base.py
@@
-2,20
+2,26
@@
Provides the BaseController class for subclassing.
"""
Provides the BaseController class for subclassing.
"""
-from pylons import session, tmpl_context as c
from pylons.controllers import WSGIController
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, request, session, tmpl_context as c
+from routes import request_config
from floof import model
from floof import model
-from floof.model
import meta
+from floof.model
.users import User
class BaseController(WSGIController):
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:
# 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:
except:
+ c.user = None
pass
def __call__(self, environ, start_response):
pass
def __call__(self, environ, start_response):
@@
-23,7
+29,18
@@
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']
# WSGIController.__call__ dispatches to the Controller method
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']
+
+ # Insert any code to be run per request here.
+
try:
return WSGIController.__call__(self, environ, start_response)
finally:
try:
return WSGIController.__call__(self, environ, start_response)
finally:
- meta.Session.remove()
+ 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)