cb7c74670abcc5f18e70932c86b354fdb7d726b4
1 """The base Controller API
3 Provides the BaseController class for subclassing.
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
10 from pylons
import session
, tmpl_context
as c
11 from floof
.model
.users
import User
13 class BaseController(WSGIController
):
15 # NOTE: This could have been implemented as a middleware =]
16 def __before__(self
, action
, **params
):
17 # Fetch current user object
19 c
.user
= User
.query
.get(session
['user_id'])
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']
29 # Insert any code to be run per request here.
32 return WSGIController
.__call__(self
, environ
, start_response
)
34 model
.Session
.remove()