[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - IToIRegistry.py:1.1.4.10
Jim Fulton
jim@zope.com
Fri, 22 Feb 2002 14:02:06 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv14827
Modified Files:
Tag: Zope-3x-branch
IToIRegistry.py
Log Message:
Added the type registry, which lets us register data for object types.
=== Zope3/lib/python/Zope/ComponentArchitecture/IToIRegistry.py 1.1.4.9 => 1.1.4.10 ===
class IRegistry(IToIRegistry):
+ """Registry for components that provide an interface but down require one
+
+ For example, this is used for registering utilities and resources.
+ """
def register(self, provide, c):
'''
@@ -100,6 +104,7 @@
self._registerAll(None, provide, c, provide)
class DataRegistry(IToIRegistry):
+ """XXX need doc for this"""
def register(self, provide, c):
'''
@@ -108,6 +113,11 @@
self._registerAll(None, provide, c, provide)
class IToIDataRegistry(IToIRegistry):
+ """Store data accociated with two interfaces
+
+ This is used for default view names, which are registered for
+ specific presentation types and object types.
+ """
def register(self, require, provide, data):
'''
@@ -115,3 +125,24 @@
provide interface.
'''
self._registerAll(require, provide, data, provide)
+
+class TypeRegistry(IToIRegistry):
+ """Register data for objects of a given type.
+
+ Type is expressed by an interface.
+
+ For example, this allows us to register subscription lists by event types.
+ """
+
+ def register(self, require, data):
+ '''
+ Registers data for combination of a require and a
+ provide interface.
+ '''
+ self._registerAll(require, None, data, None)
+
+ def getForObject(self, ob):
+ for i in objectImplements(ob):
+ c=self.get(i, None)
+ if c is not None: return c
+ return self.get(None, None)