changeset 527:53839883cab6

[SF#502951] adding new properties to old database
author Richard Jones <richard@users.sourceforge.net>
date Mon, 14 Jan 2002 06:32:34 +0000
parents 523b22a2c021
children 72fe808ff5b8
files CHANGES.txt roundup/hyperdb.py
diffstat 2 files changed, 29 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Mon Jan 14 05:16:51 2002 +0000
+++ b/CHANGES.txt	Mon Jan 14 06:32:34 2002 +0000
@@ -17,6 +17,7 @@
    config attriubute on the db. This means that all config is obtained from
    instance_config instead of the mish-mash of classes. This will make
    switching to a ConfigParser setup easier too, I hope.
+ . #502951 ] adding new properties to old database
 
 
 2002-01-08 - 0.4.0b1
--- a/roundup/hyperdb.py	Mon Jan 14 05:16:51 2002 +0000
+++ b/roundup/hyperdb.py	Mon Jan 14 06:32:34 2002 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: hyperdb.py,v 1.47 2002-01-14 02:20:15 richard Exp $
+# $Id: hyperdb.py,v 1.48 2002-01-14 06:32:34 richard Exp $
 
 __doc__ = """
 Hyperdatabase implementation, especially field types.
@@ -364,6 +364,7 @@
             if isinstance(prop, Multilink):
                 propvalues[key] = []
             else:
+                # TODO: None isn't right here, I think...
                 propvalues[key] = None
 
         # convert all data to strings
@@ -395,13 +396,21 @@
         if propname == 'id':
             return nodeid
 
+        # get the property (raises KeyErorr if invalid)
+        prop = self.properties[propname]
+
         # get the node's dict
         d = self.db.getnode(self.classname, nodeid, cache=cache)
-        if not d.has_key(propname) and default is not _marker:
-            return default
 
-        # get the value
-        prop = self.properties[propname]
+        if not d.has_key(propname):
+            if default is _marker:
+                if isinstance(prop, Multilink):
+                    return []
+                else:
+                    # TODO: None isn't right here, I think...
+                    return None
+            else:
+                return default
 
         # possibly convert the marshalled data to instances
         if isinstance(prop, Date):
@@ -519,8 +528,11 @@
                 value = l
                 propvalues[key] = value
 
-                #handle removals
-                l = node[key]
+                # handle removals
+                if node.has_key(key):
+                    l = node[key]
+                else:
+                    l = []
                 for id in l[:]:
                     if id in value:
                         continue
@@ -1029,6 +1041,15 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.47  2002/01/14 02:20:15  richard
+#  . changed all config accesses so they access either the instance or the
+#    config attriubute on the db. This means that all config is obtained from
+#    instance_config instead of the mish-mash of classes. This will make
+#    switching to a ConfigParser setup easier too, I hope.
+#
+# At a minimum, this makes migration a _little_ easier (a lot easier in the
+# 0.5.0 switch, I hope!)
+#
 # Revision 1.46  2002/01/07 10:42:23  richard
 # oops
 #

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