Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1235:7441653e5330 | 1236:dd52bf10f934 |
|---|---|
| 1 # $Id: back_sqlite.py,v 1.5 2002-09-24 01:59:28 richard Exp $ | 1 # $Id: back_sqlite.py,v 1.6 2002-09-27 01:04:38 richard Exp $ |
| 2 __doc__ = ''' | 2 __doc__ = ''' |
| 3 See https://pysqlite.sourceforge.net/ for pysqlite info | 3 See https://pysqlite.sourceforge.net/ for pysqlite info |
| 4 ''' | 4 ''' |
| 5 import base64, marshal | 5 import base64, marshal |
| 6 from roundup.backends.rdbms_common import * | 6 from roundup.backends.rdbms_common import * |
| 22 if str(error) != 'no such table: schema': | 22 if str(error) != 'no such table: schema': |
| 23 raise | 23 raise |
| 24 self.database_schema = {} | 24 self.database_schema = {} |
| 25 self.cursor.execute('create table schema (schema varchar)') | 25 self.cursor.execute('create table schema (schema varchar)') |
| 26 self.cursor.execute('create table ids (name varchar, num integer)') | 26 self.cursor.execute('create table ids (name varchar, num integer)') |
| 27 | |
| 28 def close(self): | |
| 29 ''' Close off the connection. | |
| 30 | |
| 31 Squash any error caused by us already having closed the | |
| 32 connection. | |
| 33 ''' | |
| 34 try: | |
| 35 self.conn.close() | |
| 36 except sqlite.ProgrammingError, value: | |
| 37 if str(value) != 'close failed - Connection is closed.': | |
| 38 raise | |
| 39 | |
| 40 | |
| 41 def rollback(self): | |
| 42 ''' Reverse all actions from the current transaction. | |
| 43 | |
| 44 Undo all the changes made since the database was opened or the | |
| 45 last commit() or rollback() was performed. | |
| 46 | |
| 47 Squash any error caused by us having closed the connection (and | |
| 48 therefore not having anything to roll back) | |
| 49 ''' | |
| 50 if __debug__: | |
| 51 print >>hyperdb.DEBUG, 'rollback', (self,) | |
| 52 | |
| 53 # roll back | |
| 54 try: | |
| 55 self.conn.rollback() | |
| 56 except sqlite.ProgrammingError, value: | |
| 57 if str(value) != 'rollback failed - Connection is closed.': | |
| 58 raise | |
| 59 | |
| 60 # roll back "other" transaction stuff | |
| 61 for method, args in self.transactions: | |
| 62 # delete temporary files | |
| 63 if method == self.doStoreFile: | |
| 64 self.rollbackStoreFile(*args) | |
| 65 self.transactions = [] | |
| 27 | 66 |
| 28 def __repr__(self): | 67 def __repr__(self): |
| 29 return '<roundlite 0x%x>'%id(self) | 68 return '<roundlite 0x%x>'%id(self) |
| 30 | 69 |
| 31 def sql_fetchone(self): | 70 def sql_fetchone(self): |
