sqlite-fix: Auto-commit on HTTPResponde exceptions (e.g. redirects)
This commit is contained in:
parent
31486d5066
commit
f0b377857e
9
bottle_sqlite.py
Normal file → Executable file
9
bottle_sqlite.py
Normal file → Executable file
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user