|
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 $ |
2 | 2 |
|
3 | 3 | import re, os, smtplib, socket |
4 | 4 |
|
@@ -27,6 +27,7 @@ def uidFromAddress(self, address): |
27 | 27 | return self.user.create(username=address, address=address, |
28 | 28 | realname=realname) |
29 | 29 |
|
| 30 | +# XXX: added the 'creator' faked attribute |
30 | 31 | class Class(hyperdb.Class): |
31 | 32 | # Overridden methods: |
32 | 33 | def __init__(self, db, classname, **properties): |
@@ -70,6 +71,42 @@ def retire(self, nodeid): |
70 | 71 | for react in self.reactors['retire']: |
71 | 72 | react(self.db, self, nodeid, None) |
72 | 73 |
|
| 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 | + |
73 | 110 | # New methods: |
74 | 111 |
|
75 | 112 | def audit(self, event, detector): |
@@ -145,25 +182,6 @@ def __init__(self, db, classname, **properties): |
145 | 182 | raise ValueError, '"creation", "activity" and "creator" are reserved' |
146 | 183 | Class.__init__(self, db, classname, **properties) |
147 | 184 |
|
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 | | - |
167 | 185 | # New methods: |
168 | 186 |
|
169 | 187 | def addmessage(self, nodeid, summary, text): |
@@ -227,6 +245,9 @@ def sendmessage(self, nodeid, msgid): |
227 | 245 |
|
228 | 246 | # |
229 | 247 | # $Log: not supported by cvs2svn $ |
| 248 | +# Revision 1.2 2001/07/22 12:09:32 richard |
| 249 | +# Final commit of Grande Splite |
| 250 | +# |
230 | 251 | # Revision 1.1 2001/07/22 11:58:35 richard |
231 | 252 | # More Grande Splite |
232 | 253 | # |
0 commit comments