[Zope3-checkins] CVS: Zope3/src/zope/component - factory.py:1.4 interfaces.py:1.11

Sidnei da Silva sidnei at x3ng.com.br
Tue Aug 5 11:25:47 EDT 2003


Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv14539/src/zope/component

Modified Files:
	factory.py interfaces.py 
Log Message:
Reasonably big batch of changes. Added methods to query factories by interface. Added tests for them. Registered all fields from zope.schema as factories. Added basic tests for that. Made the contentdirective use a dottedname instead of a class as the id when an id is not provided. Cleanspace Whitening here and there.

=== Zope3/src/zope/component/factory.py 1.3 => 1.4 ===
--- Zope3/src/zope/component/factory.py:1.3	Wed Jun  4 05:09:45 2003
+++ Zope3/src/zope/component/factory.py	Tue Aug  5 10:25:13 2003
@@ -63,6 +63,18 @@
         except KeyError:
             raise ComponentLookupError(name)
 
+    def getFactoriesFor(self, iface):
+        """See IFactoryService interface"""
+        factories = self.queryFactoriesFor(iface, None)
+        if factories is None:
+            raise ComponentLookupError(iface)
+        return factories
+
+    def queryFactoriesFor(self, iface, default=None):
+        """See IFactoryService interface"""
+        return [factory for factory in self.__factories.values() \
+                if iface in factory.getInterfaces()] or default
+
     _clear = __init__
 
 # the global factory service instance (see component.zcml )


=== Zope3/src/zope/component/interfaces.py 1.10 => 1.11 ===
--- Zope3/src/zope/component/interfaces.py:1.10	Sun Jul 13 00:25:10 2003
+++ Zope3/src/zope/component/interfaces.py	Tue Aug  5 10:25:13 2003
@@ -326,6 +326,20 @@
         """returns the interface or interface tuple that
         object instances created by the named factory will implement."""
 
+    def getFactoriesFor(iface):
+        """Return list of registered factories that create objects
+        which implement the given interface
+
+        A ComponentLookupError will be
+        raised if the factory component can't be found.
+        """
+
+    def queryFactoriesFor(iface, default=None):
+        """Return list of registered factories that create objects
+        which implement the given interface
+
+        If no factory is found, the default value is returned.
+        """
 
 class IUtilityService(Interface):
 




More information about the Zope3-Checkins mailing list