]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/lib/base.py
19129d432671a110d4186fad7873f4d4d70e8f76
[bluechips.git] / bluechips / lib / base.py
1 """The base Controller API
2
3 Provides the BaseController class for subclassing.
4 """
5 from pylons import tmpl_context as c
6 from pylons.controllers import WSGIController
7 from pylons.i18n import _, ungettext, N_
8 from pylons.templating import render_mako as render
9
10 import bluechips.lib.helpers as h
11 from bluechips import model
12 from bluechips.model import meta
13
14
15 class BaseController(WSGIController):
16
17     def __call__(self, environ, start_response):
18         """Invoke the Controller"""
19         # WSGIController.__call__ dispatches to the Controller method
20         # the request is routed to. This routing information is
21         # available in environ['pylons.routes_dict']
22         try:
23             return WSGIController.__call__(self, environ, start_response)
24         finally:
25             meta.Session.remove()
26
27 def update_sar(record, form_result):
28     """
29     Update a SQLAlchemy record with the results of a validated form submission
30     """
31     for key, value in form_result.items():
32         setattr(record, key, value)
33
34 __all__ = ['c', 'h', 'render', 'model', 'meta', '_', 'ungettext', 'N_',
35            'BaseController', 'update_sar']