Skip to content

Commit 6603280

Browse files
author
Richard Jones
committed
Moved the database backends off into backends.
1 parent e155e6d commit 6603280

File tree

3 files changed

+55
-28
lines changed

3 files changed

+55
-28
lines changed

roundup/backends/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import _bsddb; bsddb = _bsddb
2+
import _anydbm; anydbm = _anydbm
3+
4+
__all__ = ['bsddb', 'anydbm']

roundup/roundupdb.py

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: roundupdb.py,v 1.2 2001-07-22 12:09:32 richard Exp $
1+
# $Id: roundupdb.py,v 1.3 2001-07-23 07:14:41 richard Exp $
22

33
import re, os, smtplib, socket
44

@@ -27,6 +27,7 @@ def uidFromAddress(self, address):
2727
return self.user.create(username=address, address=address,
2828
realname=realname)
2929

30+
# XXX: added the 'creator' faked attribute
3031
class Class(hyperdb.Class):
3132
# Overridden methods:
3233
def __init__(self, db, classname, **properties):
@@ -70,6 +71,42 @@ def retire(self, nodeid):
7071
for react in self.reactors['retire']:
7172
react(self.db, self, nodeid, None)
7273

74+
def get(self, nodeid, propname):
75+
"""Attempts to get the "creation" or "activity" properties should
76+
do the right thing
77+
"""
78+
if propname == 'creation':
79+
journal = self.db.getjournal(self.classname, nodeid)
80+
if journal:
81+
return self.db.getjournal(self.classname, nodeid)[0][1]
82+
else:
83+
# on the strange chance that there's no journal
84+
return date.Date()
85+
if propname == 'activity':
86+
journal = self.db.getjournal(self.classname, nodeid)
87+
if journal:
88+
return self.db.getjournal(self.classname, nodeid)[-1][1]
89+
else:
90+
# on the strange chance that there's no journal
91+
return date.Date()
92+
if propname == 'creator':
93+
journal = self.db.getjournal(self.classname, nodeid)
94+
if journal:
95+
name = self.db.getjournal(self.classname, nodeid)[0][2]
96+
else:
97+
return None
98+
return self.db.user.lookup(name)
99+
return hyperdb.Class.get(self, nodeid, propname)
100+
101+
def getprops(self):
102+
"""In addition to the actual properties on the node, these
103+
methods provide the "creation" and "activity" properties."""
104+
d = hyperdb.Class.getprops(self).copy()
105+
d['creation'] = hyperdb.Date()
106+
d['activity'] = hyperdb.Date()
107+
d['creator'] = hyperdb.Link("user")
108+
return d
109+
73110
# New methods:
74111

75112
def audit(self, event, detector):
@@ -145,25 +182,6 @@ def __init__(self, db, classname, **properties):
145182
raise ValueError, '"creation", "activity" and "creator" are reserved'
146183
Class.__init__(self, db, classname, **properties)
147184

148-
def get(self, nodeid, propname):
149-
if propname == 'creation':
150-
return self.db.getjournal(self.classname, nodeid)[0][1]
151-
if propname == 'activity':
152-
return self.db.getjournal(self.classname, nodeid)[-1][1]
153-
if propname == 'creator':
154-
name = self.db.getjournal(self.classname, nodeid)[0][2]
155-
return self.db.user.lookup(name)
156-
return Class.get(self, nodeid, propname)
157-
158-
def getprops(self):
159-
"""In addition to the actual properties on the node, these
160-
methods provide the "creation" and "activity" properties."""
161-
d = Class.getprops(self).copy()
162-
d['creation'] = hyperdb.Date()
163-
d['activity'] = hyperdb.Date()
164-
d['creator'] = hyperdb.Link("user")
165-
return d
166-
167185
# New methods:
168186

169187
def addmessage(self, nodeid, summary, text):
@@ -227,6 +245,9 @@ def sendmessage(self, nodeid, msgid):
227245

228246
#
229247
# $Log: not supported by cvs2svn $
248+
# Revision 1.2 2001/07/22 12:09:32 richard
249+
# Final commit of Grande Splite
250+
#
230251
# Revision 1.1 2001/07/22 11:58:35 richard
231252
# More Grande Splite
232253
#

roundup/templates/extended/dbinit.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
# $Id: dbinit.py,v 1.2 2001-07-23 06:25:50 richard Exp $
1+
# $Id: dbinit.py,v 1.3 2001-07-23 07:14:41 richard Exp $
22

3-
import instance_config
4-
from roundup import hyperdb, backends.bsddb, roundupdb, cgi_client, mailgw
5-
6-
from roundup.roundupdb import Class, FileClass
73
import os
84

5+
import instance_config
6+
from roundup import roundupdb, cgi_client, mailgw
7+
from roundup.backends import bsddb
8+
from roundup.roundupdb import Class, FileClass
99

10-
class Database(roundupdb.Database, backends.bsddb.Database):
10+
class Database(roundupdb.Database, bsddb.Database):
1111
''' Creates a hybrid database from:
12-
. the base Database class given in hyperdb (basic functionlity)
13-
. the BSDDB implementation in hyperdb_bsddb
12+
. the BSDDB implementation in backends.bsddb
1413
. the roundup extensions from roundupdb
1514
'''
1615
pass
@@ -172,6 +171,9 @@ def init(adminpw):
172171

173172
#
174173
# $Log: not supported by cvs2svn $
174+
# Revision 1.2 2001/07/23 06:25:50 richard
175+
# relfected the move to roundup/backends
176+
#
175177
# Revision 1.1 2001/07/23 04:33:21 anthonybaxter
176178
# split __init__.py into 2. dbinit and instance_config.
177179
#

0 commit comments

Comments
 (0)