[Commits] (vajda) changed PersistentCollections constructors to not
use *
commits at osafoundation.org
commits at osafoundation.org
Wed Jul 14 12:29:49 PDT 2004
Commit by: vajda
Modified files:
chandler/repository/item/Item.py 1.137 1.138
chandler/repository/item/PersistentCollections.py 1.12 1.13
Log message:
changed PersistentCollections constructors to not use *
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.137&r2=text&tr2=1.138
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/PersistentCollections.py.diff?r1=text&tr1=1.12&r2=text&tr2=1.13
Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.137 chandler/repository/item/Item.py:1.138
--- chandler/repository/item/Item.py:1.137 Wed Jul 7 14:43:50 2004
+++ chandler/repository/item/Item.py Wed Jul 14 12:29:48 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.137 $"
-__date__ = "$Date: 2004/07/07 21:43:50 $"
+__revision__ = "$Revision: 1.138 $"
+__date__ = "$Date: 2004/07/14 19:29:48 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -406,7 +406,7 @@
else:
companion = self.getAttributeAspect(name, 'companion',
default=None)
- value = PersistentList(self, name, companion, *value)
+ value = PersistentList(self, name, companion, value)
self._values[name] = value
elif isinstance(value, dict):
@@ -421,7 +421,7 @@
else:
companion = self.getAttributeAspect(name, 'companion',
default=None)
- value = PersistentDict(self, name, companion, **value)
+ value = PersistentDict(self, name, companion, value)
self._values[name] = value
elif isinstance(value, ItemValue):
@@ -892,8 +892,8 @@
else:
companion = self.getAttributeAspect(attribute, 'companion',
default=None)
- attrValue = PersistentList(self, attribute, companion,
- value)
+ attrValue = PersistentList(self, attribute, companion)
+ attrValue.append(value)
_attrDict[attribute] = attrValue
return attrValue
Index: chandler/repository/item/PersistentCollections.py
diff -u chandler/repository/item/PersistentCollections.py:1.12 chandler/repository/item/PersistentCollections.py:1.13
--- chandler/repository/item/PersistentCollections.py:1.12 Fri May 21 15:21:38 2004
+++ chandler/repository/item/PersistentCollections.py Wed Jul 14 12:29:48 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.12 $"
-__date__ = "$Date: 2004/05/21 22:21:38 $"
+__revision__ = "$Revision: 1.13 $"
+__date__ = "$Date: 2004/07/14 19:29:48 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -69,10 +69,10 @@
value = value._copy(self._item, self._attribute, self._companion)
elif isinstance(value, list):
value = PersistentList(self._item, self._attribute,
- self._companion, *value)
+ self._companion, value)
elif isinstance(value, dict):
value = PersistentDict(self._item, self._attribute,
- self._companion, **value)
+ self._companion, value)
elif isinstance(value, repository.item.Item.Item):
value = SingleRef(value._uuid)
elif isinstance(value, repository.item.Values.ItemValue):
@@ -82,7 +82,7 @@
def _restoreValue(self, value):
- if isinstance(value, SingleRef):
+ if self._item is not None and isinstance(value, SingleRef):
uuid = value.itsUUID
if self._companion is None:
return self._item.find(uuid)
@@ -102,17 +102,17 @@
class PersistentList(list, PersistentCollection):
'A persistence aware list, tracking changes into a dirty bit.'
- def __init__(self, item, attribute, companion, *args):
+ def __init__(self, item, attribute, companion, initialValues=None):
list.__init__(self)
PersistentCollection.__init__(self, item, attribute, companion)
- if args:
- self.extend(args)
+ if initialValues is not None:
+ self.extend(initialValues)
def _copy(self, item, attribute, companion):
- return type(self)(item, attribute, companion, *self)
+ return type(self)(item, attribute, companion, self)
def __setitem__(self, index, value):
@@ -192,11 +192,12 @@
def extend(self, value):
+ values = []
for v in value:
self._storeValue(v)
- value = [self._prepareValue(v) for v in value]
+ values.append(self._prepareValue(v))
self._setDirty()
- super(PersistentList, self).extend(value)
+ super(PersistentList, self).extend(values)
def __getitem__(self, key):
@@ -229,17 +230,17 @@
class PersistentDict(dict, PersistentCollection):
'A persistence aware dict, tracking changes into a dirty bit.'
- def __init__(self, item, attribute, companion, **kwds):
+ def __init__(self, item, attribute, companion, initialValues=None):
dict.__init__(self)
PersistentCollection.__init__(self, item, attribute, companion)
- if kwds:
- self.update(kwds)
+ if initialValues is not None:
+ self.update(initialValues)
def _copy(self, item, attribute, companion):
- return type(self)(item, attribute, companion, **self)
+ return type(self)(item, attribute, companion, self)
def __delitem__(self, key):
@@ -260,12 +261,12 @@
def update(self, value):
- self._storeValue(value)
- dictionary = {}
+ values = {}
for k, v in value.iteritems():
- dictionary[k] = self._prepareValue(v)
+ self._storeValue(v)
+ values[k] = self._prepareValue(v)
self._setDirty()
- super(PersistentDict, self).update(dictionary)
+ super(PersistentDict, self).update(values)
def setdefault(self, key, value=None):
More information about the Commits
mailing list