Skip to content

Commit 09acb27

Browse files
author
Richard Jones
committed
[SF#502951] adding new properties to old database
1 parent b77addc commit 09acb27

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Fixed:
1717
config attriubute on the db. This means that all config is obtained from
1818
instance_config instead of the mish-mash of classes. This will make
1919
switching to a ConfigParser setup easier too, I hope.
20+
. #502951 ] adding new properties to old database
2021

2122

2223
2002-01-08 - 0.4.0b1

roundup/hyperdb.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.47 2002-01-14 02:20:15 richard Exp $
18+
# $Id: hyperdb.py,v 1.48 2002-01-14 06:32:34 richard Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -364,6 +364,7 @@ def create(self, **propvalues):
364364
if isinstance(prop, Multilink):
365365
propvalues[key] = []
366366
else:
367+
# TODO: None isn't right here, I think...
367368
propvalues[key] = None
368369

369370
# convert all data to strings
@@ -395,13 +396,21 @@ def get(self, nodeid, propname, default=_marker, cache=1):
395396
if propname == 'id':
396397
return nodeid
397398

399+
# get the property (raises KeyErorr if invalid)
400+
prop = self.properties[propname]
401+
398402
# get the node's dict
399403
d = self.db.getnode(self.classname, nodeid, cache=cache)
400-
if not d.has_key(propname) and default is not _marker:
401-
return default
402404

403-
# get the value
404-
prop = self.properties[propname]
405+
if not d.has_key(propname):
406+
if default is _marker:
407+
if isinstance(prop, Multilink):
408+
return []
409+
else:
410+
# TODO: None isn't right here, I think...
411+
return None
412+
else:
413+
return default
405414

406415
# possibly convert the marshalled data to instances
407416
if isinstance(prop, Date):
@@ -519,8 +528,11 @@ class or a KeyError is raised.
519528
value = l
520529
propvalues[key] = value
521530

522-
#handle removals
523-
l = node[key]
531+
# handle removals
532+
if node.has_key(key):
533+
l = node[key]
534+
else:
535+
l = []
524536
for id in l[:]:
525537
if id in value:
526538
continue
@@ -1029,6 +1041,15 @@ def Choice(name, *options):
10291041

10301042
#
10311043
# $Log: not supported by cvs2svn $
1044+
# Revision 1.47 2002/01/14 02:20:15 richard
1045+
# . changed all config accesses so they access either the instance or the
1046+
# config attriubute on the db. This means that all config is obtained from
1047+
# instance_config instead of the mish-mash of classes. This will make
1048+
# switching to a ConfigParser setup easier too, I hope.
1049+
#
1050+
# At a minimum, this makes migration a _little_ easier (a lot easier in the
1051+
# 0.5.0 switch, I hope!)
1052+
#
10321053
# Revision 1.46 2002/01/07 10:42:23 richard
10331054
# oops
10341055
#

0 commit comments

Comments
 (0)