]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/lib/base.py
Switch from using Decimal to using a new Currency class
[bluechips.git] / bluechips / lib / base.py
index 260943f78f2d1dc75aab627c16634d59d6f7393b..2a9786c6cad857e909ef8c731174e04c37c8418a 100644 (file)
@@ -27,7 +27,7 @@ class BaseController(WSGIController):
                 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['pylons.routes_dict']['action'] == 'index':
                 environ['PATH_INFO'] += '/'
                 raise HTTPMovedPermanently(construct_url(environ))
         try:
@@ -35,5 +35,13 @@ class BaseController(WSGIController):
         finally:
             meta.Session.remove()
 
+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', 'render_response', 'validate',
-           'model', 'meta', '_', 'ungettext', 'N_', 'BaseController']
+           'model', 'meta', '_', 'ungettext', 'N_', 'BaseController',
+           'update_sar']