From 49d66e82d09c127299c1d31c9a88c692fb3cbe92 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 30 Jul 2001 02:38:31 +0000 Subject: [PATCH] get() now has a default arg - for migration only. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@162 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/hyperdb.py | 10 ++++++++-- roundup/roundupdb.py | 23 +++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 252194c..ea37bdd 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -1,4 +1,4 @@ -# $Id: hyperdb.py,v 1.9 2001-07-29 09:28:23 richard Exp $ +# $Id: hyperdb.py,v 1.10 2001-07-30 02:38:31 richard Exp $ # standard python modules import cPickle, re, string @@ -58,6 +58,7 @@ class Database: RETIRED_FLAG = '__hyperdb_retired' +_marker = [] # # The base Class class # @@ -192,7 +193,7 @@ class Class: self.db.addjournal(self.classname, newid, 'create', propvalues) return newid - def get(self, nodeid, propname): + def get(self, nodeid, propname, default=_marker): """Get the value of a property on an existing node of this class. 'nodeid' must be the id of an existing node of this class or an @@ -203,6 +204,8 @@ class Class: return nodeid # nodeid = str(nodeid) d = self.db.getnode(self.classname, nodeid) + if not d.has_key(propname) and default is not _marker: + return default return d[propname] # XXX not in spec @@ -790,6 +793,9 @@ def Choice(name, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.9 2001/07/29 09:28:23 richard +# Fixed sorting by clicking on column headings. +# # Revision 1.8 2001/07/29 08:27:40 richard # Fixed handling of passed-in values in form elements (ie. during a # drill-down) diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index cd9fa0e..5b33f30 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -1,4 +1,4 @@ -# $Id: roundupdb.py,v 1.6 2001-07-30 00:05:54 richard Exp $ +# $Id: roundupdb.py,v 1.7 2001-07-30 02:38:31 richard Exp $ import re, os, smtplib, socket @@ -27,6 +27,7 @@ class Database: return self.user.create(username=address, address=address, realname=realname) +_marker = [] # XXX: added the 'creator' faked attribute class Class(hyperdb.Class): # Overridden methods: @@ -71,9 +72,9 @@ class Class(hyperdb.Class): for react in self.reactors['retire']: react(self.db, self, nodeid, None) - def get(self, nodeid, propname): + def get(self, nodeid, propname, default=_marker): """Attempts to get the "creation" or "activity" properties should - do the right thing + do the right thing. """ if propname == 'creation': journal = self.db.getjournal(self.classname, nodeid) @@ -96,7 +97,10 @@ class Class(hyperdb.Class): else: return None return self.db.user.lookup(name) - return hyperdb.Class.get(self, nodeid, propname) + if default is not _marker: + return hyperdb.Class.get(self, nodeid, propname, default) + else: + return hyperdb.Class.get(self, nodeid, propname) def getprops(self): """In addition to the actual properties on the node, these @@ -145,12 +149,15 @@ class FileClass(Class): ''' return open(self.filename(classname, nodeid), 'rb').read() - def get(self, nodeid, propname): + def get(self, nodeid, propname, default=_marker): ''' trap the content propname and get it from the file ''' if propname == 'content': return self.getcontent(self.classname, nodeid) - return Class.get(self, nodeid, propname) + if default is not _marker: + return Class.get(self, nodeid, propname, default) + else: + return Class.get(self, nodeid, propname) def getprops(self): ''' In addition to the actual properties on the node, these methods @@ -247,6 +254,10 @@ class IssueClass(Class): # # $Log: not supported by cvs2svn $ +# Revision 1.6 2001/07/30 00:05:54 richard +# Fixed IssueClass so that superseders links to its classname rather than +# hard-coded to "issue". +# # Revision 1.5 2001/07/29 07:01:39 richard # Added vim command to all source so that we don't get no steenkin' tabs :) # -- 2.30.2