[Zope3-dev] two small bugs in zc.relationship
Markus Kemmerling
markus.kemmerling at meduniwien.ac.at
Mon Jul 2 08:24:55 EDT 2007
Hi,
I discovered two smalll bugs in `zc.relationship`. The first is just
a typo in the `ManyToOneRelationship` convenience class of the
`shared`module:
@@ -149,7 +149,7 @@
interface.implements(interfaces.IManyToOneRelationship)
def __init__(self, sources, target):
- super(OneToManyRelationship, self).__init__(sources, (target,))
+ super(ManyToOneRelationShip, self).__init__((sources,),
target) @apply
def sources():
The second is a little bit more subtle. The `findRelationships`
method misbehaves if both, `source` and `target`, are not None, but
`bool(target)` evaluates to False. The fix is equally easy (and
similar to the `isLinked` method):
@@ -292,7 +292,7 @@
res = self.relationIndex.findRelationshipTokenChains(
tokenize({'source': source}),
maxDepth, filter and ResolvingFilter(filter, self),
- target and tokenize({'target': target}),
+ target is not None and tokenize({'target': target})
or None,
targetFilter=minDepthFilter(minDepth))
return self._forward(res)
elif target is not None:
I discovered the last one when relating to a `target` that is a full
blown Zope object but also happens to be a yet empty container. It
certainly makes sense that an empty dictionary is considered to be
`False` when converted to a boolean. But I wouldn't have expected a
non built-in type, that *also* supports the mapping API, to be
considered as `False` as long as the mapping is empty ...
Markus Kemmerling
More information about the Zope3-dev
mailing list