[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - GlobalFactoryService.py:1.4 IFactoryService.py:1.3 __init__.py:1.3

Jim Fulton jim@zope.com
Thu, 20 Jun 2002 16:01:00 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv19918/lib/python/Zope/ComponentArchitecture

Modified Files:
	GlobalFactoryService.py IFactoryService.py __init__.py 
Log Message:

Gary and Jim implemented most of:
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/AddMenuProposalAndEndOfZmiNamespace

A lot of clean up is needed, including:

- Implementation additional add menus, for example for services.

- Ripping out old unused implementation.





=== Zope3/lib/python/Zope/ComponentArchitecture/GlobalFactoryService.py 1.3 => 1.4 ===
     def createObject(self, name, *args, **kwargs):
         """See IFactoryService interface"""
-        try: return self.__factories[name](*args, **kwargs)
+        try:
+            return self.__factories[name](*args, **kwargs)
         except KeyError:
             raise ComponentLookupError(name)
+
+    def getFactory(self, name):
+        """See IFactoryService interface"""
+        try:
+            return self.__factories[name]
+        except KeyError:
+            raise ComponentLookupError(name)
+
+    def queryFactory(self, name, default=None):
+        """See IFactoryService interface"""
+        return self.__factories.get(name, default)
     
     def getInterfaces(self, name):
         """See IFactoryService interface"""


=== Zope3/lib/python/Zope/ComponentArchitecture/IFactoryService.py 1.2 => 1.3 ===
         raised if the factory component can't be found.
         """
+
+    def getFactory(name):
+        """Return a registered factory
+
+        A Zope.ComponentArchitecture.ComponentLookupError will be
+        raised if the factory component can't be found.
+        """
+
+    def queryFactory(name, default=None):
+        """Return a registered factory
+        """
+
     def getInterfaces(name):
         """returns the interface or interface tuple that
         object instances created by the named factory will implement."""
-    
\ No newline at end of file
+    


=== Zope3/lib/python/Zope/ComponentArchitecture/__init__.py 1.2 => 1.3 ===
     return getService(context, 'Factories').createObject(name, *args, **kwargs)
 
+def getFactory(context, name):
+    return getService(context, 'Factories').getFactory(name)
+
+def queryFactory(context, name, default=None):
+    return getService(context, 'Factories').queryFactory(name, default)
+
 def getFactoryInterfaces(context, name):
     return getService(context, 'Factories').getInterfaces(name)