[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ Fixed bug reported by Egon: factories did not provide a correct link to

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Feb 27 17:23:59 EST 2005


Log message for revision 29325:
  Fixed bug reported by Egon: factories did not provide a correct link to 
  the object.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/component.py
  U   Zope3/trunk/src/zope/app/apidoc/component.txt
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.py	2005-02-27 21:54:18 UTC (rev 29324)
+++ Zope3/trunk/src/zope/app/apidoc/component.py	2005-02-27 22:23:59 UTC (rev 29325)
@@ -133,6 +133,9 @@
     """
     if isinstance(factory, types.FunctionType) and hasattr(factory, 'factory'):
         return factory.factory
+    elif not hasattr(factory, '__name__'):
+        # We have an instance
+        return factory.__class__
     return factory
 
 
@@ -157,6 +160,7 @@
     """Return a PT-friendly info dictionary for an adapter registration."""
     factory = getRealFactory(reg.value)
     path = getPythonPath(factory)
+
     if isinstance(factory, types.MethodType):
        url = None
     else:
@@ -183,16 +187,21 @@
 def getFactoryInfoDictionary(reg):
     """Return a PT-friendly info dictionary for a factory."""
     factory = reg.component
-    if type(factory) in (types.ClassType, types.TypeType):
-        klass = factory
-    else:
-        klass = factory.__class__
-    path = getPythonPath(klass)
 
+    callable = factory
+
+    if IFactory.providedBy(factory):
+        callable = factory._callable
+
+    elif hasattr(callable, '__class__'):
+        callable = callable.__class__
+
+    path = getPythonPath(callable)
+
     return {'name': reg.name or '<i>no name</i>',
             'title': getattr(factory, 'title', u''),
             'description': renderText(getattr(factory, 'description', u''),
-                                      module=klass.__module__),
+                                      module=callable.__module__),
             'url': path.replace('.', '/')}
 
 

Modified: Zope3/trunk/src/zope/app/apidoc/component.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.txt	2005-02-27 21:54:18 UTC (rev 29324)
+++ Zope3/trunk/src/zope/app/apidoc/component.txt	2005-02-27 22:23:59 UTC (rev 29325)
@@ -281,7 +281,7 @@
   {'description': u'<div class="document">\nMy Foo Bar</div>\n',
    'name': 'MyFooBar',
    'title': 'MyFooBar',
-   'url': 'zope/component/factory/Factory'}
+   'url': '__builtin__/MyFooBar'}
 
 
 `getUtilityInfoDictionary(name, factory)`

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt	2005-02-27 21:54:18 UTC (rev 29324)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt	2005-02-27 22:23:59 UTC (rev 29325)
@@ -339,7 +339,7 @@
   [{'description': u'',
     'name': 'FooFactory',
     'title': 'Foo Factory',
-    'url': 'zope/component/factory/Factory'}]
+    'url': '__builtin__/Foo'}]
 
 `getUtilities()`
 ----------------



More information about the Zope3-Checkins mailing list