rudimentary file uploading. Saves as sha1 like git objects. code is in lib. needs...
[zzz-floof.git] / floof / lib / base.py
index fd6ee47..4de5e19 100644 (file)
@@ -2,19 +2,24 @@
 
 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 floof.model import meta
+from floof.model.users import User
 
 class BaseController(WSGIController):
 
+    def __before__(self, action, **params):
+        # 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']
-        try:
-            return WSGIController.__call__(self, environ, start_response)
-        finally:
-            meta.Session.remove()
+        return WSGIController.__call__(self, environ, start_response)