summaryrefslogtreecommitdiff
path: root/index.py
diff options
context:
space:
mode:
Diffstat (limited to 'index.py')
-rwxr-xr-xindex.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/index.py b/index.py
index b91418d..d9e2e7d 100755
--- a/index.py
+++ b/index.py
@@ -2,6 +2,7 @@
import web
import controller
+import model
#
# URL Mappings
@@ -12,11 +13,31 @@ urls = (
)
#
+# ORM
+#
+def handle_sql(handler):
+ web.ctx.orm = session = model.session
+
+ try:
+ return handler()
+ except web.HTTPError:
+ session.commit()
+ raise
+ except:
+ session.rollback()
+ raise
+ else:
+ session.commit()
+
+#
# The App
#
app = web.application(urls, globals())
app.notfound = controller.FourOhFour
+# add orm processor
+app.add_processor(handle_sql)
+
# debug for the moment
web.config.debug = True