Mercurial > p > roundup > code
annotate roundup/backends/back_bsddb3.py @ 2633:a9e1fff1e793
I thought I committed this last night. Ho hum.
- This implements most of the rest of the new tracker config layout:
- dbinit.py split between schema.py and initial_data.py
- interfaces.py gone
- tracker and detectors __init__.py gone
- Added some missing functionality to backends: db_exists test and db_nuke.
- Implemented configuration file options in postgresql backend.
- Cleaned up tracker initialisation a lot.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 27 Jul 2004 00:57:19 +0000 |
| parents | 091711fb2f8c |
| children | 11811b313459 |
| rev | line source |
|---|---|
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
1 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
3 # This module is free software, and you may redistribute it and/or modify |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
4 # under the same terms as Python, so long as this copyright message and |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
5 # disclaimer are retained in their original form. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
6 # |
| 214 | 7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR |
|
213
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
10 # POSSIBILITY OF SUCH DAMAGE. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
11 # |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
|
d45384bc6420
Added the copyright/license notice to (nearly) all files...
Richard Jones <richard@users.sourceforge.net>
parents:
196
diff
changeset
|
17 # |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
18 #$Id: back_bsddb3.py,v 1.25 2004-07-27 00:57:18 richard Exp $ |
|
2005
fc52d57c6c3e
documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents:
1920
diff
changeset
|
19 '''This module defines a backend that saves the hyperdatabase in BSDDB3. |
|
1244
8dd4f736370b
merge from maintenance branch
Richard Jones <richard@users.sourceforge.net>
parents:
1143
diff
changeset
|
20 ''' |
|
2005
fc52d57c6c3e
documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents:
1920
diff
changeset
|
21 __docformat__ = 'restructuredtext' |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
23 import bsddb3, os, marshal, errno, shutil |
|
726
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
24 from roundup import hyperdb, date |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
25 |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
26 # these classes are so similar, we just use the anydbm methods |
|
858
2dd862af72ee
all storage-specific code (ie. backend) is now implemented by the backends
Richard Jones <richard@users.sourceforge.net>
parents:
815
diff
changeset
|
27 from back_anydbm import Database, Class, FileClass, IssueClass |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
28 |
|
2633
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
29 def db_exists(config): |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
30 return os.path.exists(os.path.join(config.TRACKER_HOME, 'db', 'user')) |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
31 |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
32 def db_nuke(config): |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
33 shutil.rmtree(os.path.join(config.TRACKER_HOME, 'db')) |
|
a9e1fff1e793
I thought I committed this last night. Ho hum.
Richard Jones <richard@users.sourceforge.net>
parents:
2514
diff
changeset
|
34 |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
35 # |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
36 # Now the database |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
37 # |
|
858
2dd862af72ee
all storage-specific code (ie. backend) is now implemented by the backends
Richard Jones <richard@users.sourceforge.net>
parents:
815
diff
changeset
|
38 class Database(Database): |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
39 """A database for storing records containing flexible data types.""" |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
40 # |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
41 # Class DBs |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
42 # |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
43 def clear(self): |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
44 for cn in self.classes.keys(): |
|
2251
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
45 for name in 'nodes.%s'%cn, 'journals.%s'%cn: |
|
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
46 try: |
|
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
47 os.remove(os.path.join(self.dir, name)) |
|
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
48 except os.error, error: |
|
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
49 if error.errno != errno.ENOENT: |
|
01b5afc087ae
fix bsddb3 for 4.2.xx DB_TRUNCATE change
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
50 raise |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
51 |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
52 def getclassdb(self, classname, mode='r'): |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
53 ''' grab a connection to the class db that will be used for |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
54 multiple actions |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
55 ''' |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
56 path = os.path.join(os.getcwd(), self.dir, 'nodes.%s'%classname) |
|
152
80c062af1b7d
Handle non-existence of db files in the other backends (code from anydbm).
Richard Jones <richard@users.sourceforge.net>
parents:
149
diff
changeset
|
57 if os.path.exists(path): |
|
80c062af1b7d
Handle non-existence of db files in the other backends (code from anydbm).
Richard Jones <richard@users.sourceforge.net>
parents:
149
diff
changeset
|
58 return bsddb3.btopen(path, mode) |
|
80c062af1b7d
Handle non-existence of db files in the other backends (code from anydbm).
Richard Jones <richard@users.sourceforge.net>
parents:
149
diff
changeset
|
59 else: |
|
815
f4ead46205ac
Was reopening the database with 'n'.
Richard Jones <richard@users.sourceforge.net>
parents:
726
diff
changeset
|
60 return bsddb3.btopen(path, 'c') |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
61 |
|
891
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
62 def opendb(self, name, mode): |
|
726
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
63 '''Low-level database opener that gets around anydbm/dbm |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
64 eccentricities. |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
65 ''' |
|
726
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
66 # determine which DB wrote the class file |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
67 path = os.path.join(os.getcwd(), self.dir, name) |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
68 if not os.path.exists(path): |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
69 if __debug__: |
|
2514
091711fb2f8c
Initial logging integration: replace all debug prints with logging calls...
Richard Jones <richard@users.sourceforge.net>
parents:
2251
diff
changeset
|
70 self.config.logging.getLogger('hyperdb').debug("opendb bsddb3.open(%r, 'c')"%path) |
|
815
f4ead46205ac
Was reopening the database with 'n'.
Richard Jones <richard@users.sourceforge.net>
parents:
726
diff
changeset
|
71 return bsddb3.btopen(path, 'c') |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
72 |
|
726
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
73 # open the database with the correct module |
|
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
74 if __debug__: |
|
2514
091711fb2f8c
Initial logging integration: replace all debug prints with logging calls...
Richard Jones <richard@users.sourceforge.net>
parents:
2251
diff
changeset
|
75 self.config.logging.getLogger('hyperdb').debug("opendb bsddb3.open(%r, %r)"%(path, mode)) |
|
726
e3d742c75ac3
Well whadya know, bsddb3 works again.
Richard Jones <richard@users.sourceforge.net>
parents:
524
diff
changeset
|
76 return bsddb3.btopen(path, mode) |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
77 |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
78 # |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
79 # Journal |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
80 # |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
81 def getjournal(self, classname, nodeid): |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
82 ''' get the journal for id |
|
1631
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
83 |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
84 Raise IndexError if the node doesn't exist (as per history()'s |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
85 API) |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
86 ''' |
|
1631
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
87 # our journal result |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
88 res = [] |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
89 |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
90 # add any journal entries for transactions not committed to the |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
91 # database |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
92 for method, args in self.transactions: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
93 if method != self.doSaveJournal: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
94 continue |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
95 (cache_classname, cache_nodeid, cache_action, cache_params, |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
96 cache_creator, cache_creation) = args |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
97 if cache_classname == classname and cache_nodeid == nodeid: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
98 if not cache_creator: |
|
1800
a3b1b1dcf639
Use getuid(), not figure_curuserid()
Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
parents:
1631
diff
changeset
|
99 cache_creator = self.getuid() |
|
1631
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
100 if not cache_creation: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
101 cache_creation = date.Date() |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
102 res.append((cache_nodeid, cache_creation, cache_creator, |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
103 cache_action, cache_params)) |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
104 |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
105 # attempt to open the journal - in some rare cases, the journal may |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
106 # not exist |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
107 try: |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
108 db = bsddb3.btopen(os.path.join(self.dir, 'journals.%s'%classname), |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
109 'r') |
|
891
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
110 except bsddb3._db.DBNoSuchFileError: |
|
1920
f9316d2cd5ba
Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents:
1800
diff
changeset
|
111 if res: |
|
f9316d2cd5ba
Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents:
1800
diff
changeset
|
112 # we have unsaved journal entries, return them |
|
f9316d2cd5ba
Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents:
1800
diff
changeset
|
113 return res |
|
891
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
114 raise IndexError, 'no such %s %s'%(classname, nodeid) |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
115 # more handling of bad journals |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
116 if not db.has_key(nodeid): |
|
1631
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
117 db.close() |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
118 if res: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
119 # we have some unsaved journal entries, be happy! |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
120 return res |
|
891
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
121 raise IndexError, 'no such %s %s'%(classname, nodeid) |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
122 journal = marshal.loads(db[nodeid]) |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
123 db.close() |
|
1631
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
124 |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
125 # add all the saved journal entries for this node |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
126 for nodeid, date_stamp, user, action, params in journal: |
|
8a908bbad1ef
A couple of form value handling changes:
Richard Jones <richard@users.sourceforge.net>
parents:
1244
diff
changeset
|
127 res.append((nodeid, date.Date(date_stamp), user, action, params)) |
|
64
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
128 return res |
|
8bce2210ef81
bsddb3 implementation.
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
diff
changeset
|
129 |
|
891
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
130 def getCachedJournalDB(self, classname): |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
131 ''' get the journal db, looking in our cache of databases for commit |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
132 ''' |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
133 # get the database handle |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
134 db_name = 'journals.%s'%classname |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
135 if self.databases.has_key(db_name): |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
136 return self.databases[db_name] |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
137 else: |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
138 db = bsddb3.btopen(os.path.join(self.dir, db_name), 'c') |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
139 self.databases[db_name] = db |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
140 return db |
|
974a4b94c5e3
Implemented the destroy() method needed by the session database...
Richard Jones <richard@users.sourceforge.net>
parents:
858
diff
changeset
|
141 |
