[Zope-CVS] CVS: Packages/pypes/pypes - extent.py:1.4
Casey Duncan
casey at zope.com
Mon Feb 16 00:18:22 EST 2004
Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv21753
Modified Files:
extent.py
Log Message:
Simplify and generalize constructor of extent service
=== Packages/pypes/pypes/extent.py 1.3 => 1.4 ===
--- Packages/pypes/pypes/extent.py:1.3 Sun Feb 15 23:44:57 2004
+++ Packages/pypes/pypes/extent.py Mon Feb 16 00:17:51 2004
@@ -222,7 +222,9 @@
class ClassExtentMap(Persistent):
- """Object extents by class"""
+ """Object extents by class
+
+ Dependancies: Identity Service, Event Service"""
implements(IExtentMap)
@@ -230,6 +232,7 @@
_extent_factory = Extent
def __init__(self, dbconn):
+ """Create the class extent map. dbconn is an open ZODB connection"""
self._subclasses = OOBTree() # Map class key => set of subclass keys
self._instances = OOBTree() # Map class key => id set of instances
listenForIdEvents(self, dbconn)
@@ -312,31 +315,20 @@
class ExtentService(Persistent):
- """Extent service managing class and interface extents.
-
- Dependancies: Identity Service, Event Service
+ """Extent service managing class and interface extents. The service is
+ basically a facade which delegates to extent maps which handle extents
+ for keys of a specific type, such as classes or interfaces.
"""
implements(IExtentService)
- # Map factory hooks for testing/overriding
- _class_map_factory = ClassExtentMap
- _interface_map_factory = InterfaceExtentMap
-
- def __init__(self, dbconn, class_extents=True, interface_extents=True):
- """Create an extent service. By default both class extents and
- interface extents are enabled. You may override this by specifying
- the appropriate keyword argument. At least one extent type must
- be enabled. dbconn is an open ZODB connection object.
+ def __init__(self, *extent_maps):
+ """Create an extent service containing the specified extent maps.
"""
- assert class_extents or interface_extents, (
- 'Cannot create service with neither class nor interface '
- 'extents enabled.')
- self._extent_maps = []
- if class_extents:
- self._extent_maps.append(self._class_map_factory(dbconn))
- if interface_extents:
- self._extent_maps.append(self._interface_map_factory(dbconn))
+ assert extent_maps, (
+ 'Cannot create extent service with '
+ 'no extent maps specified.')
+ self._extent_maps = extent_maps
def __getitem__(self, key):
for extent_map in self._extent_maps:
More information about the Zope-CVS
mailing list