[Zope3-checkins] SVN: Zope3/trunk/ Fixed issue 664, http://www.zope.org/Collectors/Zope3-dev/664.

Jim Fulton jim at zope.com
Tue Jul 18 13:23:09 EDT 2006


Log message for revision 69177:
  Fixed issue 664, http://www.zope.org/Collectors/Zope3-dev/664.
  
  The introspector didn't properly handle attributes that showd up in
  dir() but that weren't gettable.
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/apidoc/utilities.py
  U   Zope3/trunk/src/zope/app/apidoc/utilities.txt

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-07-18 17:20:27 UTC (rev 69176)
+++ Zope3/trunk/doc/CHANGES.txt	2006-07-18 17:23:05 UTC (rev 69177)
@@ -16,6 +16,13 @@
 
     Bug fixes
 
+      - Fixed issue 664, apidoc didn't properly handle attributes that
+        showd up in dir() but that weren't gettable.
+
+      - Fixed issue 604, Mutable schemas were accidentally included in
+        the 3.2 release even though they weren't ready and didn't
+        work. They are not included in the 3.3 release.
+
       - Fixed issue 564: binary set operations didn't work on proxied sets.
 
       - Fixed issue 572: Dict fields with key_type or value_type set

Modified: Zope3/trunk/src/zope/app/apidoc/utilities.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilities.py	2006-07-18 17:20:27 UTC (rev 69176)
+++ Zope3/trunk/src/zope/app/apidoc/utilities.py	2006-07-18 17:23:05 UTC (rev 69177)
@@ -227,8 +227,14 @@
     for attr in dir(obj):
         if attr.startswith('_'):
             continue
-        else:
-            attrs.append(attr)
+        
+        try:
+            getattr(obj, attr)
+        except AttributeError:
+            continue
+
+        attrs.append(attr)
+
     return attrs
 
 def getInterfaceForAttribute(name, interfaces=_marker, klass=_marker,

Modified: Zope3/trunk/src/zope/app/apidoc/utilities.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilities.txt	2006-07-18 17:20:27 UTC (rev 69176)
+++ Zope3/trunk/src/zope/app/apidoc/utilities.txt	2006-07-18 17:23:05 UTC (rev 69177)
@@ -477,6 +477,10 @@
 
 First we need to create a class with some attributes, properties and methods:
 
+  >>> class Nonattr(object):
+  ...     def __get__(*a):
+  ...         raise AttributeError('nonattr')
+
   >>> class Sample(object):
   ...     attr = None
   ...     def __str__(self):
@@ -486,6 +490,8 @@
   ...     def _getAttr(self):
   ...         return self.attr
   ...     attr2 = property(_getAttr)
+  ...
+  ...     nonattr = Nonattr() # Should not show up in public attrs
 
 We can simply pass in the class and get the public attributes:
 
@@ -494,6 +500,9 @@
   >>> attrs
   ['attr', 'attr2', 'func']
 
+Note that we exclude attributes that would raise attribute errors,
+like our silly Nonattr.
+
 But an instance of that class will work as well.
 
   >>> attrs = utilities.getPublicAttributes(Sample())
@@ -752,4 +761,4 @@
 often safer (if available):
 
   >>> utilities.renderText('Hello!\n', module=apidoc)
-  u'<p>Hello!</p>\n'
\ No newline at end of file
+  u'<p>Hello!</p>\n'



More information about the Zope3-Checkins mailing list