]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/lib/base.py
require at least one non-zero share on an expenditure
[bluechips.git] / bluechips / lib / base.py
index 260943f78f2d1dc75aab627c16634d59d6f7393b..19129d432671a110d4186fad7873f4d4d70e8f76 100644 (file)
@@ -5,15 +5,12 @@ Provides the BaseController class for subclassing.
 from pylons import tmpl_context as c
 from pylons.controllers import WSGIController
 from pylons.i18n import _, ungettext, N_
-
-from tw.mods.pylonshf import render, render_response, validate
+from pylons.templating import render_mako as render
 
 import bluechips.lib.helpers as h
 from bluechips import model
 from bluechips.model import meta
 
-from paste.request import construct_url
-from paste.httpexceptions import HTTPMovedPermanently
 
 class BaseController(WSGIController):
 
@@ -22,18 +19,17 @@ class BaseController(WSGIController):
         # WSGIController.__call__ dispatches to the Controller method
         # the request is routed to. This routing information is
         # available in environ['pylons.routes_dict']
-        if environ['pylons.routes_dict']['controller'] != 'error':
-            if environ['PATH_INFO'].endswith('/index'):
-                environ['PATH_INFO'] = environ['PATH_INFO'][:-5]
-                raise HTTPMovedPermanently(construct_url(environ))
-            if not environ['PATH_INFO'].endswith('/') and \
-                    environ['pylons.routes_dict']['action'] is 'index':
-                environ['PATH_INFO'] += '/'
-                raise HTTPMovedPermanently(construct_url(environ))
         try:
             return WSGIController.__call__(self, environ, start_response)
         finally:
             meta.Session.remove()
 
-__all__ = ['c', 'h', 'render', 'render_response', 'validate',
-           'model', 'meta', '_', 'ungettext', 'N_', 'BaseController']
+def update_sar(record, form_result):
+    """
+    Update a SQLAlchemy record with the results of a validated form submission
+    """
+    for key, value in form_result.items():
+        setattr(record, key, value)
+
+__all__ = ['c', 'h', 'render', 'model', 'meta', '_', 'ungettext', 'N_',
+           'BaseController', 'update_sar']