[Zope-Coders] docstring checking and __bobo_traverse__ broken, perhaps

Steve Alexander steve@cat-box.net
Thu, 11 Oct 2001 10:26:09 +0100


In ZPublisher/BaseRequest.py, we have this:

----
if hasattr(object,'__bobo_traverse__'):
     subobject=object.__bobo_traverse__(request,entry_name)
     if type(subobject) is type(()) and len(subobject) > 1:
         # Add additional parents into the path
         parents[-1:] = list(subobject[:-1])
         object, subobject = subobject[-2:]
else:

   <various stuff snipped>

# Ensure that the object has a docstring, or that the parent
# object has a pseudo-docstring for the object. Objects that
# have an empty or missing docstring are not published.
doc = getattr(subobject, '__doc__', None)
if doc is None:
     doc = getattr(object, '%s__doc__' % entry_name, None)
if not doc:
     return response.debugError(
         "The object at %s has an empty or missing " \
         "docstring. Objects must have a docstring to be " \
         "published." % URL
         )
----

The problem is that if you're publishing "virtual" objects using 
__bobo_traverse__, the code still checks for the existence of a docstring.

Is this a bug or a feature?

Should I be able to return strings directly from __bobo_traverse__ ?

I suspect that the behaviour was changed when the more descriptive 
docstring error message was introduced.


If this is a bug, not a feature, I volunteer to produce the fix. :-)

--
Steve Alexander
Software Engineer
Cat-Box limited