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 @@
     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,
             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
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to