[Commits] (vajda) - reviewed patches from Morgen and Donn
commits at osafoundation.org
commits at osafoundation.org
Tue Aug 3 04:25:03 PDT 2004
Commit by: vajda
Modified files:
chandler/repository/item/Item.py 1.148 1.149
chandler/repository/schema/Cloud.py 1.10 1.11
Log message:
- reviewed patches from Morgen and Donn
- added type checks to Item.addValue() and Item.setValue(), case of RefDict
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.148&r2=text&tr2=1.149
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Cloud.py.diff?r1=text&tr1=1.10&r2=text&tr2=1.11
Index: chandler/repository/schema/Cloud.py
diff -u chandler/repository/schema/Cloud.py:1.10 chandler/repository/schema/Cloud.py:1.11
--- chandler/repository/schema/Cloud.py:1.10 Mon Aug 2 22:47:23 2004
+++ chandler/repository/schema/Cloud.py Tue Aug 3 04:25:02 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.10 $"
-__date__ = "$Date: 2004/08/03 05:47:23 $"
+__revision__ = "$Revision: 1.11 $"
+__date__ = "$Date: 2004/08/03 11:25:02 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -79,7 +79,7 @@
else:
results = []
- for alias, endpoint, cloud in self.iterEndpoints(cloudAlias):
+ for alias, endpoint, inCloud in self.iterEndpoints(cloudAlias):
for other in endpoint.iterValues(item):
if other is not None and other._uuid not in items:
results.extend(endpoint.getItems(other, items, references,
@@ -115,7 +115,10 @@
list.
@param item: the entry point of the cloud.
- @type item: an C{Item} instance
+ @type item: an C{Item<repository.item.Item.Item>} instance
+ @param parent: the optional parent of the copies; by default, each
+ copy gets the same parent as the original
+ @type parent: an C{Item<repository.item.Item.Item>} instance
@param copies: an optional dictionary keyed on the original item
UUIDs that also received all items copies.
@type items: dict
@@ -161,7 +164,7 @@
def getAttributeEndpoints(self, attrName, index=0, cloudAlias=None):
endpoints = []
- for alias, endpoint, cloud in self.iterEndpoints(cloudAlias):
+ for alias, endpoint, inCloud in self.iterEndpoints(cloudAlias):
names = endpoint.attribute
if index < len(names) and names[index] == attrName:
endpoints.append(endpoint)
@@ -195,6 +198,16 @@
by going up the cloud kind's superKind chain and horizontally by
iterating over the cloud kind's superKinds.
+ The iterator yields C{(alias, endpoint, inCloud)} tuples, where:
+
+ - C{alias} is the alias of the endpoint in {cloud}'s
+ C{endpoints} ref collection.
+
+ - C{endpoint} is an C{Endpoint<repository.schema.Cloud.Endpoint>}
+ instance.
+
+ - C{inCloud} is the cloud C{endpoint} is defined on.
+
If an endpoint is aliased in a cloud's endpoints collection,
endpoints by the same alias are not inherited.
"""
@@ -207,8 +220,8 @@
if cloudAlias is not None:
for superKind in self.kind._getSuperKinds():
for cloud in superKind.getClouds(cloudAlias):
- for alias, endpoint, inCloud in \
- cloud.iterEndpoints(cloudAlias):
+ for (alias, endpoint,
+ inCloud) in cloud.iterEndpoints(cloudAlias):
if (alias is None or
endpoints is None or
endpoints.resolveAlias(alias) is None):
Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.148 chandler/repository/item/Item.py:1.149
--- chandler/repository/item/Item.py:1.148 Tue Aug 3 02:17:04 2004
+++ chandler/repository/item/Item.py Tue Aug 3 04:25:02 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.148 $"
-__date__ = "$Date: 2004/08/03 09:17:04 $"
+__revision__ = "$Revision: 1.149 $"
+__date__ = "$Date: 2004/08/03 11:25:02 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -354,8 +354,6 @@
isinstance(value, RefDict))
old = None
- self.setDirty(attribute=name)
-
if _attrDict is self._references:
if value is None:
value = NoneRef
@@ -369,6 +367,7 @@
# reattaching on original endpoint
old.reattach(self, name, old.other(self), value,
self._kind.getOtherName(name))
+ self.setDirty(attribute=name)
return value
elif isRef:
# reattaching on other endpoint,
@@ -384,6 +383,8 @@
else:
raise TypeError, type(old)
+ self.setDirty(attribute=name)
+
if isItem:
otherName = self._kind.getOtherName(name, default=None)
card = self.getAttributeAspect(name, 'cardinality',
@@ -885,8 +886,11 @@
default='single')
if card == 'dict':
- if isItem and _attrDict is self._references:
- attrValue = self._refDict(attribute)
+ if _attrDict is self._references:
+ if isItem:
+ attrValue = self._refDict(attribute)
+ else:
+ raise TypeError, type(value)
else:
companion = self.getAttributeAspect(attribute, 'companion',
default=None)
@@ -896,8 +900,11 @@
return attrValue
elif card == 'list':
- if isItem and _attrDict is self._references:
- attrValue = self._refDict(attribute)
+ if _attrDict is self._references:
+ if isItem:
+ attrValue = self._refDict(attribute)
+ else:
+ raise TypeError, type(value)
else:
companion = self.getAttributeAspect(attribute, 'companion',
default=None)
@@ -912,8 +919,11 @@
_attrDict[attribute] = attrValue
- if isItem:
- attrValue.append(value, alias)
+ if _attrDict is self._references:
+ if isItem:
+ attrValue.append(value, alias)
+ else:
+ raise TypeError, type(value)
else:
attrValue[key] = value
@@ -965,20 +975,20 @@
else:
_attrDict = self._values
- isItem = isinstance(value, Item)
attrValue = _attrDict.get(attribute, Item.Nil)
-
if attrValue is Item.Nil:
return self.setValue(attribute, value, key, alias, _attrDict)
else:
self.setDirty(attribute=attribute)
- if isinstance(attrValue, dict):
- if isItem and _attrDict is self._references:
+ if isinstance(attrValue, RefDict):
+ if isinstance(value, Item):
attrValue.append(value, alias)
else:
- attrValue[key] = value
+ raise TypeError, type(value)
+ elif isinstance(attrValue, dict):
+ attrValue[key] = value
elif isinstance(attrValue, list):
attrValue.append(value)
else:
@@ -1344,14 +1354,15 @@
if policy == 'copy':
return other
elif policy == 'cascade':
- copyOther = copies.get(other.itsUUID, None)
- if copyOther is None:
+ otherCopy = copies.get(other.itsUUID, None)
+ if otherCopy is None:
if self.itsParent is copy.itsParent:
parent = other.itsParent
else:
parent = copy.itsParent
- copyOther = other.copy(None, parent, copies, copyPolicy)
- return copyOther
+ otherCopy = other.copy(None, parent, copies, copyPolicy,
+ None, copyOther)
+ return otherCopy
else:
return None
More information about the Commits
mailing list