4de5e19450976a012097b37f619a1aed320a28f1
[zzz-floof.git] / floof / lib / base.py
1 """The base Controller API
2
3 Provides the BaseController class for subclassing.
4 """
5 from pylons import session, tmpl_context as c
6 from pylons.controllers import WSGIController
7 from pylons.templating import render_mako as render
8
9 from floof.model.users import User
10
11 class BaseController(WSGIController):
12
13 def __before__(self, action, **params):
14 # Fetch current user object
15 try:
16 c.user = User.query.get(session['user_id'])
17 except:
18 pass
19
20 def __call__(self, environ, start_response):
21 """Invoke the Controller"""
22 # WSGIController.__call__ dispatches to the Controller method
23 # the request is routed to. This routing information is
24 # available in environ['pylons.routes_dict']
25 return WSGIController.__call__(self, environ, start_response)