[Zope-Checkins] CVS: Zope/lib/python/ComponentArchitecture - FactoryComponents.py:1.1.2.5 InterfaceComponents.py:1.1.2.6

Shane Hathaway shane@digicool.com
Tue, 7 Aug 2001 18:32:06 -0400


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

Modified Files:
      Tag: NR-branch
	FactoryComponents.py InterfaceComponents.py 
Log Message:
- Updated to correspond to changes in the Interface package.

- Getting closer to real, working labeled instance factories.


=== Zope/lib/python/ComponentArchitecture/FactoryComponents.py 1.1.2.4 => 1.1.2.5 ===
      GlobalInputToNameRegistry, getRealization, listComponentNames
 from Content import ContentContainer
+import Acquisition
 
 
 FACTORY_SERVICE_NAME = 'factories'
@@ -102,6 +103,9 @@
 class FactoryComponent (InputToNameComponent):
     '''
     '''
+    def construct():
+        '''
+        '''
 
 
 global_reg = GlobalInputToNameRegistry()
@@ -127,7 +131,7 @@
                               object, inputs)
 
 
-class SimpleFactory:
+class SimpleFactory (Acquisition.Explicit):
 
     __implements__ = FactoryComponent
 
@@ -149,6 +153,9 @@
     def isEnabled(self):
         return 1
 
+    def construct(self):
+        return self.__dict__['constructor']()
+
 
 def provideSimpleFactory(klass, ui_name=None, inputs=(ContentContainer,)):
     fullname = '%s.%s' % (klass.__module__, klass.__name__)
@@ -156,5 +163,5 @@
         ui_name = fullname
     sf = SimpleFactory(fullname, ui_name, inputs, klass)
     for input in inputs:
-        global_reg.provideRealization(input, fullname, sf)
+        global_reg.provideRealization(input, fullname, sf.__of__)
 


=== Zope/lib/python/ComponentArchitecture/InterfaceComponents.py 1.1.2.5 => 1.1.2.6 ===
 import Errors
 import Interface
+from Interface import CLASS_INTERFACES
 from NameProvider import NameProviderService, NameProviderComponent, \
      GlobalNameRegistry, getRealization, listComponentNames
 
@@ -130,22 +131,9 @@
         name = i.getName()
     global_reg.provideRealization(name, i)
 
-def flattenInterfaceList(object, interfaces, append):
-    # Helper for objectImplements().
-    for i in interfaces:
-        if isinstance(i, Interface):
-            append(i)
-        elif type(i) is StringType:
-            # Look up the interface.
-            iface = getInterface(object, i, None)
-            if iface is not None:
-                append(iface)
-        else:
-            flattenInterfaceList(object, i, append)
-
 def objectImplements(object):
     '''
     Dereferences labels.
     '''
-    return Interface.objectImplements(
-        object, flattenfunc=flattenInterfaceList)
+    return Interface.objectImplements(object, getInterface=getInterface)
+