comparison roundup/roundupdb.py @ 262:ab921dc53ccd

Added nicer command-line item adding: passing no arguments will enter an interactive more which asks for each property in turn. While I was at it, I fixed an implementation problem WRT the spec - I wasn't raising a ValueError if the key property was missing from a create(). Also added a protected=boolean argument to getprops() so we can list only the mutable properties (defaults to yes, which lists the immutables).
author Richard Jones <richard@users.sourceforge.net>
date Thu, 04 Oct 2001 02:12:42 +0000
parents 18134bffab37
children e13d55912cd4
comparison
equal deleted inserted replaced
261:0ca5381a72b5 262:ab921dc53ccd
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: roundupdb.py,v 1.10 2001-08-07 00:24:42 richard Exp $ 18 # $Id: roundupdb.py,v 1.11 2001-10-04 02:12:42 richard Exp $
19 19
20 import re, os, smtplib, socket 20 import re, os, smtplib, socket
21 21
22 import hyperdb, date 22 import hyperdb, date
23 23
31 def getuid(self): 31 def getuid(self):
32 """Return the id of the "user" node associated with the user 32 """Return the id of the "user" node associated with the user
33 that owns this connection to the hyperdatabase.""" 33 that owns this connection to the hyperdatabase."""
34 return self.user.lookup(self.journaltag) 34 return self.user.lookup(self.journaltag)
35 35
36 def uidFromAddress(self, address): 36 def uidFromAddress(self, address, create=1):
37 ''' address is from the rfc822 module, and therefore is (name, addr) 37 ''' address is from the rfc822 module, and therefore is (name, addr)
38 38
39 user is created if they don't exist in the db already 39 user is created if they don't exist in the db already
40 ''' 40 '''
41 (realname, address) = address 41 (realname, address) = address
117 if default is not _marker: 117 if default is not _marker:
118 return hyperdb.Class.get(self, nodeid, propname, default) 118 return hyperdb.Class.get(self, nodeid, propname, default)
119 else: 119 else:
120 return hyperdb.Class.get(self, nodeid, propname) 120 return hyperdb.Class.get(self, nodeid, propname)
121 121
122 def getprops(self): 122 def getprops(self, protected=1):
123 """In addition to the actual properties on the node, these 123 """In addition to the actual properties on the node, these
124 methods provide the "creation" and "activity" properties.""" 124 methods provide the "creation" and "activity" properties. If the
125 "protected" flag is true, we include protected properties - those
126 which may not be modified.
127 """
125 d = hyperdb.Class.getprops(self).copy() 128 d = hyperdb.Class.getprops(self).copy()
126 d['creation'] = hyperdb.Date() 129 if protected:
127 d['activity'] = hyperdb.Date() 130 d['creation'] = hyperdb.Date()
128 d['creator'] = hyperdb.Link("user") 131 d['activity'] = hyperdb.Date()
132 d['creator'] = hyperdb.Link("user")
129 return d 133 return d
130 134
131 # 135 #
132 # Detector interface 136 # Detector interface
133 # 137 #
174 if default is not _marker: 178 if default is not _marker:
175 return Class.get(self, nodeid, propname, default) 179 return Class.get(self, nodeid, propname, default)
176 else: 180 else:
177 return Class.get(self, nodeid, propname) 181 return Class.get(self, nodeid, propname)
178 182
179 def getprops(self): 183 def getprops(self, protected=1):
180 ''' In addition to the actual properties on the node, these methods 184 ''' In addition to the actual properties on the node, these methods
181 provide the "content" property. 185 provide the "content" property. If the "protected" flag is true,
186 we include protected properties - those which may not be
187 modified.
182 ''' 188 '''
183 d = Class.getprops(self).copy() 189 d = Class.getprops(self).copy()
184 d['content'] = hyperdb.String() 190 if protected:
191 d['content'] = hyperdb.String()
185 return d 192 return d
186 193
187 # XXX deviation from spec - was called ItemClass 194 # XXX deviation from spec - was called ItemClass
188 class IssueClass(Class): 195 class IssueClass(Class):
189 # Overridden methods: 196 # Overridden methods:
280 %s 287 %s
281 '''%('_'*len(web), self.ISSUE_TRACKER_EMAIL, web) 288 '''%('_'*len(web), self.ISSUE_TRACKER_EMAIL, web)
282 289
283 # 290 #
284 # $Log: not supported by cvs2svn $ 291 # $Log: not supported by cvs2svn $
292 # Revision 1.10 2001/08/07 00:24:42 richard
293 # stupid typo
294 #
285 # Revision 1.9 2001/08/07 00:15:51 richard 295 # Revision 1.9 2001/08/07 00:15:51 richard
286 # Added the copyright/license notice to (nearly) all files at request of 296 # Added the copyright/license notice to (nearly) all files at request of
287 # Bizar Software. 297 # Bizar Software.
288 # 298 #
289 # Revision 1.8 2001/08/02 06:38:17 richard 299 # Revision 1.8 2001/08/02 06:38:17 richard

Roundup Issue Tracker: http://roundup-tracker.org/