So, I'm having a very difficult time creating a lazr.restful test for this problem. I have a test case and a code fix for Launchpad, but I'm in a twisty maze of hurt trying to reproduce the problem in lazr.restful itself.
In addition to the default traversal implementation, this publication
also handles traversal to collection scoped into an entry.
"""
# If this is the last traversal step, then look first for a scoped
# collection. This is done because although Navigation handles
# traversal to entries in a scoped collection, they don't usually
# handle traversing to the scoped collection itself.
if len(request.getTraversalStack()) == 0:
try: entry = IEntry(ob)
except TypeError: pass
else: field = entry.schema.get(name)
if ICollectionField.providedBy(field): result = self._traverseToScopedCollection( request, entry, field, name) if result is not None: return result elif IBytes.providedBy(field): return self._traverseToByteStorage( request, entry, field, name) elif IObject.providedBy(field): sub_entry = getattr(entry, name, None) if sub_entry is None: raise NotFound(ob, name, request) else: return sub_entry elif field is not None: return EntryField(entry, field, name) else: # Falls through to our parent version. pass
return super(WebServicePublicationMixin, self).traverseName( request, ob, name)
Note the new goodness in the "elif IObject" stanza.
So, I'm having a very difficult time creating a lazr.restful test for this problem. I have a test case and a code fix for Launchpad, but I'm in a twisty maze of hurt trying to reproduce the problem in lazr.restful itself.
What I have so far: lp:~barry/lazr.restful.387487-subordinate
but it sucks :(
However, in src/lazr/ restful/ publisher. py, the following code fixes the
problem:
def traverseName(self, request, ob, name): .interfaces. IPublication` .
"""See `zope.publisher
In addition to the default traversal implementation, this publication getTraversalSta ck()) == 0:
entry = IEntry(ob)
pass
field = entry.schema. get(name) d.providedBy( field):
result = self._traverseT oScopedCollecti on(
request, entry, field, name)
if result is not None:
return result
elif IBytes. providedBy( field):
return self._traverseT oByteStorage(
request, entry, field, name)
elif IObject. providedBy( field):
sub_ entry = getattr(entry, name, None)
if sub_entry is None:
raise NotFound(ob, name, request)
else:
return sub_entry
elif field is not None:
return EntryField(entry, field, name)
else:
# Falls through to our parent version.
pass ePublicationMix in, self).traverseName(
request, ob, name)
also handles traversal to collection scoped into an entry.
"""
# If this is the last traversal step, then look first for a scoped
# collection. This is done because although Navigation handles
# traversal to entries in a scoped collection, they don't usually
# handle traversing to the scoped collection itself.
if len(request.
try:
except TypeError:
else:
if ICollectionFiel
return super(WebServic
Note the new goodness in the "elif IObject" stanza.