Mercurial > p > roundup > code
diff roundup/backends/back_sqlite.py @ 1236:dd52bf10f934
Bug fixes.
- fixed bug in login if the username wasn't known
- handle close/rollback of already-closed sqlite database
- added example for external passwd-style user password verification
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 27 Sep 2002 01:04:38 +0000 |
| parents | e0032f4ab334 |
| children | 209a47ede743 |
line wrap: on
line diff
--- a/roundup/backends/back_sqlite.py Thu Sep 26 23:59:08 2002 +0000 +++ b/roundup/backends/back_sqlite.py Fri Sep 27 01:04:38 2002 +0000 @@ -1,4 +1,4 @@ -# $Id: back_sqlite.py,v 1.5 2002-09-24 01:59:28 richard Exp $ +# $Id: back_sqlite.py,v 1.6 2002-09-27 01:04:38 richard Exp $ __doc__ = ''' See https://pysqlite.sourceforge.net/ for pysqlite info ''' @@ -25,6 +25,45 @@ self.cursor.execute('create table schema (schema varchar)') self.cursor.execute('create table ids (name varchar, num integer)') + def close(self): + ''' Close off the connection. + + Squash any error caused by us already having closed the + connection. + ''' + try: + self.conn.close() + except sqlite.ProgrammingError, value: + if str(value) != 'close failed - Connection is closed.': + raise + + + def rollback(self): + ''' Reverse all actions from the current transaction. + + Undo all the changes made since the database was opened or the + last commit() or rollback() was performed. + + Squash any error caused by us having closed the connection (and + therefore not having anything to roll back) + ''' + if __debug__: + print >>hyperdb.DEBUG, 'rollback', (self,) + + # roll back + try: + self.conn.rollback() + except sqlite.ProgrammingError, value: + if str(value) != 'rollback failed - Connection is closed.': + raise + + # roll back "other" transaction stuff + for method, args in self.transactions: + # delete temporary files + if method == self.doStoreFile: + self.rollbackStoreFile(*args) + self.transactions = [] + def __repr__(self): return '<roundlite 0x%x>'%id(self)
