[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - BaseRequest.py:1.41

Brian Lloyd brian@digicool.com
Thu, 13 Sep 2001 13:33:23 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv26519

Modified Files:
	BaseRequest.py 
Log Message:
Changed handling of missing docstring to be more descriptive and to
not mask missing docstring errors when not in debug mode.


=== Zope/lib/python/ZPublisher/BaseRequest.py 1.40 => 1.41 ===
                             else:
                                 return response.notFoundError(URL)
-    
-                try:
-                    try: doc=subobject.__doc__
-                    except: doc=getattr(object, entry_name+'__doc__')
-                    if not doc: raise AttributeError, entry_name
-                except:
-                    if debug_mode:
-                        return response.debugError(
-                            "Missing doc string at: %s" % URL)
-                    else: return response.notFoundError("%s" % URL)
+
+                # 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
+                        )
 
                 r = getattr(subobject, '__roles__', UNSPECIFIED_ROLES)
                 if r is not UNSPECIFIED_ROLES: