the beginnings of user-art relations. You can add relations, and it makes sure they...
[zzz-floof.git] / floof / lib / base.py
index fd6ee47..169493c 100644 (file)
@@ -4,17 +4,33 @@ Provides the BaseController class for subclassing.
 """
 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.model import meta
+from floof import model
+from floof.model.users import User
 
 class BaseController(WSGIController):
 
+    # 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 = User.query.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']
+
+        # Insert any code to be run per request here.
+
         try:
             return WSGIController.__call__(self, environ, start_response)
         finally:
-            meta.Session.remove()
+            model.Session.remove()