Mercurial > p > roundup > code
comparison roundup/backends/rdbms_common.py @ 1333:80d27b7d6db5
implemented whole-database locking
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 12 Dec 2002 09:31:04 +0000 |
| parents | 61ad556cfc8d |
| children | 618aa9c37d65 |
comparison
equal
deleted
inserted
replaced
| 1332:e2d51ba4f6b1 | 1333:80d27b7d6db5 |
|---|---|
| 1 # $Id: rdbms_common.py,v 1.24 2002-11-06 11:38:42 richard Exp $ | 1 # $Id: rdbms_common.py,v 1.25 2002-12-12 09:31:04 richard Exp $ |
| 2 ''' Relational database (SQL) backend common code. | 2 ''' Relational database (SQL) backend common code. |
| 3 | 3 |
| 4 Basics: | 4 Basics: |
| 5 | 5 |
| 6 - map roundup classes to relational tables | 6 - map roundup classes to relational tables |
| 26 | 26 |
| 27 # roundup modules | 27 # roundup modules |
| 28 from roundup import hyperdb, date, password, roundupdb, security | 28 from roundup import hyperdb, date, password, roundupdb, security |
| 29 from roundup.hyperdb import String, Password, Date, Interval, Link, \ | 29 from roundup.hyperdb import String, Password, Date, Interval, Link, \ |
| 30 Multilink, DatabaseError, Boolean, Number | 30 Multilink, DatabaseError, Boolean, Number |
| 31 from roundup.backends import locking | |
| 31 | 32 |
| 32 # support | 33 # support |
| 33 from blobfiles import FileStorage | 34 from blobfiles import FileStorage |
| 34 from roundup.indexer import Indexer | 35 from roundup.indexer import Indexer |
| 35 from sessions import Sessions | 36 from sessions import Sessions |
| 59 | 60 |
| 60 # keep a cache of the N most recently retrieved rows of any kind | 61 # keep a cache of the N most recently retrieved rows of any kind |
| 61 # (classname, nodeid) = row | 62 # (classname, nodeid) = row |
| 62 self.cache = {} | 63 self.cache = {} |
| 63 self.cache_lru = [] | 64 self.cache_lru = [] |
| 65 | |
| 66 # database lock | |
| 67 self.lockfile = None | |
| 64 | 68 |
| 65 # open a connection to the database, creating the "conn" attribute | 69 # open a connection to the database, creating the "conn" attribute |
| 66 self.open_connection() | 70 self.open_connection() |
| 67 | 71 |
| 68 def clearCache(self): | 72 def clearCache(self): |
| 901 | 905 |
| 902 def close(self): | 906 def close(self): |
| 903 ''' Close off the connection. | 907 ''' Close off the connection. |
| 904 ''' | 908 ''' |
| 905 self.conn.close() | 909 self.conn.close() |
| 910 if self.lockfile is not None: | |
| 911 locking.release_lock(self.lockfile) | |
| 912 if self.lockfile is not None: | |
| 913 self.lockfile.close() | |
| 914 self.lockfile = None | |
| 906 | 915 |
| 907 # | 916 # |
| 908 # The base Class class | 917 # The base Class class |
| 909 # | 918 # |
| 910 class Class(hyperdb.Class): | 919 class Class(hyperdb.Class): |
