Thanks for undertaking this effort. Since your cover letter was sparce, and the inline documentation is too, I am puzzled by the complexity of the issue described in the pub and simplicity of your solution.
This appears to be an easy fix for a hard problem. The problem stated in
the bug is that the suborinate object and field conflict in the name space,
but there is no conflict detection here. Are there any IObject
fields that we expect to be a field? I am sure you thought about this
since you decided this is the right solution.
Hi Barry.
Thanks for undertaking this effort. Since your cover letter was sparce, and the inline documentation is too, I am puzzled by the complexity of the issue described in the pub and simplicity of your solution.
> === modified file 'src/lazr/ restful/ publisher. py' restful/ publisher. py 2009-03-27 04:25:34 +0000 restful/ publisher. py 2009-07-24 21:16:28 +0000
> --- src/lazr/
> +++ src/lazr/
...
> def traverseName(self, request, ob, name): .interfaces. IPublication` . providedBy( field): oByteStorage( providedBy( field):
> """See `zope.publisher
> @@ -66,6 +66,12 @@
> elif IBytes.
> return self._traverseT
> request, entry, field, name)
> + elif IObject.
> + 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:
This appears to be an easy fix for a hard problem. The problem stated in
the bug is that the suborinate object and field conflict in the name space,
but there is no conflict detection here. Are there any IObject
fields that we expect to be a field? I am sure you thought about this
since you decided this is the right solution.
> === added file 'src/lazr/ restful/ tests/test_ navigation. py' restful/ tests/test_ navigation. py 1970-01-01 00:00:00 +0000 restful/ tests/test_ navigation. py 2009-07-24 21:16:28 +0000
> --- src/lazr/
> +++ src/lazr/
...
> +class Child: IChildEntry)
> + implements(
> + schema = IChild
> +
I see trailing whitespace.
...
> +class FakePublication:
> + """A fake superclass publication."""
> + def traverseName(self, request, ob, name):
> + return 'no such name: ' + name
I am confused by this. I do not see why this is need below. Are .traverseName( ) is never reached?
you testing that the FakePublication
> +class NavigationPubli cation( WebServicePubli cationMixin, FakePublication): ase(unittest. TestCase) : navigation( self): cation( ) traverseName( FakeRequest( ), Parent(), 'child') l(obj.one, 'one') navigation_ without_ subentry( self): cation( ) traverseName,
> + pass
> +
> +
> +class NavigationTestC
> +
> + def test_toplevel_
> + # Test that publication can reach sub-entries.
> + publication = NavigationPubli
> + obj = publication.
> + self.assertEqua
> +
> + def test_toplevel_
> + # Test that publication raises NotFound when subentry attribute
> + # returns None.
> + parent = Parent()
> + parent.child = None
> + publication = NavigationPubli
> + self.assertRaises(
> + NotFound, publication.
> + FakeRequest(), parent, 'child')