169493c38ddeb2d2a8c378686512209caab02fc8
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
, session
, tmpl_context
as c
8 from routes
import request_config
10 from floof
import model
11 from floof
.model
.users
import User
13 class BaseController(WSGIController
):
15 # NOTE: This could have been implemented as a middleware =]
17 c
.route
= request_config().mapper_dict
19 # Fetch current user object
21 c
.user
= User
.query
.get(session
['user_id'])
25 def __call__(self
, environ
, start_response
):
26 """Invoke the Controller"""
27 # WSGIController.__call__ dispatches to the Controller method
28 # the request is routed to. This routing information is
29 # available in environ['pylons.routes_dict']
31 # Insert any code to be run per request here.
34 return WSGIController
.__call__(self
, environ
, start_response
)
36 model
.Session
.remove()