fixed search query (awesome now thanks vee =]), tag links, default routing is back...
[zzz-floof.git] / floof / lib / base.py
1 """The base Controller API
2
3 Provides the BaseController class for subclassing.
4 """
5 from pylons.controllers import WSGIController
6 from pylons.templating import render_mako as render
7 from pylons import config
8 from floof import model
9
10 from pylons import session, tmpl_context as c
11 from floof.model.users import User
12
13 class BaseController(WSGIController):
14
15 # NOTE: This could have been implemented as a middleware =]
16 def __before__(self, action, **params):
17 # Fetch current user object
18 try:
19 c.user = User.query.get(session['user_id'])
20 except:
21 pass
22
23 def __call__(self, environ, start_response):
24 """Invoke the Controller"""
25 # WSGIController.__call__ dispatches to the Controller method
26 # the request is routed to. This routing information is
27 # available in environ['pylons.routes_dict']
28
29 # Insert any code to be run per request here.
30
31 try:
32 return WSGIController.__call__(self, environ, start_response)
33 finally:
34 model.Session.remove()