summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2012-01-10 22:01:37 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2012-01-10 22:01:37 +0100
commita5c0cd1a0f496325035fbd3f3cbb8b81e7648301 (patch)
tree50cf8500662a618b2c2d2ff7122cec5b69e50186
parent77817e08eb237c207cc93d9545c61fb30e0059a9 (diff)
downloadkosten-a5c0cd1a0f496325035fbd3f3cbb8b81e7648301.tar.gz
kosten-a5c0cd1a0f496325035fbd3f3cbb8b81e7648301.tar.bz2
kosten-a5c0cd1a0f496325035fbd3f3cbb8b81e7648301.zip
Fix bug that prevents closing sql-connections
Diffstat (limited to '')
-rw-r--r--controller.py3
-rwxr-xr-xindex.py13
-rw-r--r--model.py2
3 files changed, 10 insertions, 8 deletions
diff --git a/controller.py b/controller.py
index ea8be5b..5056306 100644
--- a/controller.py
+++ b/controller.py
@@ -193,6 +193,7 @@ class ConstAdd:
else:
e.prev = None
+ web.ctx.orm.commit()
raise web.seeother("/const/%s" % e.id)
else:
return render(self.template, form = f)
@@ -219,7 +220,7 @@ class ConstAdd:
cur = self.get_expense()
if cur.id is None: # empty
- session.expunge(cur)
+ web.ctx.orm..expunge(cur)
else:
filter = sql.or_(CE.next == cur, filter)
filter = sql.and_(filter, CE.id != cur.id)
diff --git a/index.py b/index.py
index e7687e2..1639fc4 100755
--- a/index.py
+++ b/index.py
@@ -24,18 +24,19 @@ urls = (
# ORM
#
def handle_sql(handler):
- web.ctx.orm = session = model.session
+ web.ctx.orm = model.session
try:
- return handler()
+ h = handler()
except web.HTTPError:
- session.commit()
- raise
+ web.ctx.orm.commit()
+ raise
except:
- session.rollback()
+ web.ctx.orm.rollback()
raise
else:
- session.commit()
+ web.ctx.orm.commit()
+ return h
#
# The App
diff --git a/model.py b/model.py
index e9ee2be..fc43ad7 100644
--- a/model.py
+++ b/model.py
@@ -7,7 +7,7 @@ import datetime
from functools import partial
from collections import namedtuple
-__all__ = ["Category", "SingleExpense", "ConstExpense", "CatExpense", "MonthExpense", "session"]
+__all__ = ["Category", "SingleExpense", "ConstExpense", "CatExpense", "MonthExpense"]
#
# DB Setup