From f0b377857e785f6e171f3c4c238bed3c55bfb67c Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Tue, 7 Feb 2012 19:07:27 +0100 Subject: [PATCH] sqlite-fix: Auto-commit on HTTPResponde exceptions (e.g. redirects) --- bottle_sqlite.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) mode change 100644 => 100755 bottle_sqlite.py diff --git a/bottle_sqlite.py b/bottle_sqlite.py old mode 100644 new mode 100755 index d79b592..4dae746 --- a/bottle_sqlite.py +++ b/bottle_sqlite.py @@ -27,14 +27,14 @@ Usage Example:: ''' __author__ = "Marcel Hellkamp" -__version__ = '0.1.1' +__version__ = '0.1.2' __license__ = 'MIT' ### CUT HERE (see setup.py) import sqlite3 import inspect -from bottle import HTTPError +from bottle import HTTPResponse, HTTPError class SQLitePlugin(object): @@ -89,6 +89,11 @@ class SQLitePlugin(object): except sqlite3.IntegrityError, e: db.rollback() raise HTTPError(500, "Database Error", e) + except HTTPError, e: + raise + except HTTPResponse, e: + if autocommit: db.commit() + raise finally: db.close() return rv