[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/apidoc/ifacemodule/ getFactories() method rewritten

Dmitry Vasiliev dima at hlabs.spb.ru
Wed May 19 08:26:08 EDT 2004


Log message for revision 24824:
getFactories() method rewritten



-=-
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py	2004-05-19 12:20:38 UTC (rev 24823)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py	2004-05-19 12:26:07 UTC (rev 24824)
@@ -283,7 +283,6 @@
             ('name', 'get'),
             ('signature', '(key, default=None)')]]
         """        
-        methods = []
         return [{'name': method.getName(),
                  'signature': method.getSignatureString(),
                  'doc': stx2html(method.getDoc() or '', 3)}
@@ -427,6 +426,7 @@
 
         Example::
 
+          >>> from zope.app.apidoc.tests import pprint
           >>> from tests import getInterfaceDetails
           >>> details = getInterfaceDetails()
 
@@ -434,13 +434,26 @@
           >>> factories = [f.items() for f in factories]
           >>> factories = [f for f in factories if f.sort() is None]
           >>> factories.sort()
-          >>> factories
-          [[('name', u'FooFactory'), ('title', 'Foo Factory')]]
+          >>> pprint(factories)
+          [[('name', u'FooFactory'),
+            ('title', 'Foo Factory'),
+            ('url', 'zope/component/factory/Factory')]]
         """
         iface = removeAllProxies(self.context)
-        return [{'name': n, 'title': f.title} \
-                for n, f in zapi.getFactoriesFor(self.context, iface) \
-                if iface in tuple(f.getInterfaces())]
+        factories = [(n, f) for n, f in
+                    zapi.getFactoriesFor(self.context, iface)
+                    if iface in tuple(f.getInterfaces())]
+        info = []
+        for name, factory in factories:
+            if type(factory) in (ClassType, TypeType):
+                klass = factory
+            else:
+                klass = factory.__class__
+            path = getPythonPath(klass)
+            info.append({'name': name or '<i>no name</i>',
+                         'title': getattr(factory, 'title', ''),
+                         'url': path.replace('.', '/')})
+        return info
 
     def getUtilitiesFor(self):
         """Return all utilities that provide this interface.
@@ -486,5 +499,4 @@
         iface = removeAllProxies(self.context)
         service = zapi.getService(self.context, 'Services')
         services = service.getServiceDefinitions()
-        services = filter(lambda x: x[1] is iface, services)
-        return [ser[0] for ser in services]
+        return [ser[0] for ser in services if ser[1] is iface]

Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt	2004-05-19 12:20:38 UTC (rev 24823)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/index.pt	2004-05-19 12:26:07 UTC (rev 24824)
@@ -201,7 +201,7 @@
           <ul>
             <li tal:repeat="factory factories">
               <a href=""
-                 tal:attributes="href string:../../Factory/${factory/name}/"
+                 tal:attributes="href string:../../Class/${factory/url}/"
                  tal:content="factory/name" />
               <tal:block replace="string:(${factory/title})" 
                          condition="factory/title" />




More information about the Zope3-Checkins mailing list