[Checkins] SVN: zc.catalog/trunk/ Added hook point to allow extent catalog to be used with local UID sources.
Patrick Strawderman
patrick at zope.com
Wed Sep 10 15:04:44 EDT 2008
Log message for revision 91034:
Added hook point to allow extent catalog to be used with local UID sources.
Changed:
U zc.catalog/trunk/CHANGES.txt
U zc.catalog/trunk/setup.py
U zc.catalog/trunk/src/zc/catalog/extentcatalog.py
U zc.catalog/trunk/src/zc/catalog/extentcatalog.txt
-=-
Modified: zc.catalog/trunk/CHANGES.txt
===================================================================
--- zc.catalog/trunk/CHANGES.txt 2008-09-10 16:38:26 UTC (rev 91033)
+++ zc.catalog/trunk/CHANGES.txt 2008-09-10 19:04:43 UTC (rev 91034)
@@ -2,9 +2,18 @@
CHANGES
=======
-The 1.2 line supports Zope 3.4/ZODB 3.8. The 1.1 line supports Zope
-3.3/ZODB 3.7.
+The 1.2 line (and higher) supports Zope 3.4/ZODB 3.8. The 1.1 line supports
+Zope 3.3/ZODB 3.7.
+1.3.0 (2008-09-10)
+------------------
+
+Features added
+~~~~~~~~~~~~~~
+
+* Added hook point to allow extent catalog to be used with local UID sources.
+
+
1.2.0 (2007-11-03)
------------------
Modified: zc.catalog/trunk/setup.py
===================================================================
--- zc.catalog/trunk/setup.py 2008-09-10 16:38:26 UTC (rev 91033)
+++ zc.catalog/trunk/setup.py 2008-09-10 19:04:43 UTC (rev 91034)
@@ -19,17 +19,17 @@
from setuptools import setup, find_packages
def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+ return open(os.path.join(os.path.dirname('.'), *rnames)).read()
setup(name='zc.catalog',
- version = '1.3.0dev',
+ version = '1.3.0',
author='Zope Corporation and Contributors',
author_email='zope3-dev at zope.org',
description="Extensions to the Zope 3 Catalog",
long_description=(
read('README.txt')
+ '\n\n' +
- 'Detailed Dcoumentation\n' +
+ 'Detailed Documentation\n' +
'======================\n'
+ '\n\n' +
read('src', 'zc', 'catalog', 'valueindex.txt')
Modified: zc.catalog/trunk/src/zc/catalog/extentcatalog.py
===================================================================
--- zc.catalog/trunk/src/zc/catalog/extentcatalog.py 2008-09-10 16:38:26 UTC (rev 91033)
+++ zc.catalog/trunk/src/zc/catalog/extentcatalog.py 2008-09-10 19:04:43 UTC (rev 91034)
@@ -127,7 +127,7 @@
class NonPopulatingExtent(Extent):
"""Base class for populating extent.
-
+
This simple, no-op implementation comes in handy surprisingly often
for catalogs that handle a very contained domain within an application.
"""
@@ -143,7 +143,9 @@
class Catalog(catalog.Catalog):
interface.implements(interfaces.IExtentCatalog)
- def __init__(self, extent):
+ UIDSource = None
+
+ def __init__(self, extent, UIDSource=None):
"""Construct a catalog based on an extent.
Note that the `family` keyword parameter of the base class
@@ -151,12 +153,21 @@
used.
"""
+
+ self.UIDSource = UIDSource
+
if extent.__parent__ is not None:
raise ValueError("extent's __parent__ must be None")
super(Catalog, self).__init__(family=extent.family)
self.extent = extent
extent.__parent__ = self # inform extent of catalog
+ def _getUIDSource(self):
+ res = self.UIDSource
+ if res is None:
+ res = zope.component.getUtility(IIntIds)
+ return res
+
def clear(self):
self.extent.clear()
super(Catalog, self).clear()
@@ -181,7 +192,7 @@
# not an index in us. Let the superclass handle it.
super(Catalog, self).updateIndex(index)
else:
- uidutil = zope.component.getUtility(IIntIds)
+ uidutil = self._getUIDSource()
if interfaces.ISelfPopulatingExtent.providedBy(self.extent):
if not self.extent.populated:
@@ -203,7 +214,7 @@
index.index_doc(uid, obj)
def updateIndexes(self):
- uidutil = zope.component.getUtility(IIntIds)
+ uidutil = self._getUIDSource()
if interfaces.ISelfPopulatingExtent.providedBy(self.extent):
if not self.extent.populated:
Modified: zc.catalog/trunk/src/zc/catalog/extentcatalog.txt
===================================================================
--- zc.catalog/trunk/src/zc/catalog/extentcatalog.txt 2008-09-10 16:38:26 UTC (rev 91033)
+++ zc.catalog/trunk/src/zc/catalog/extentcatalog.txt 2008-09-10 19:04:43 UTC (rev 91034)
@@ -168,6 +168,18 @@
>>> set(extent.difference(alt_set)) == original
True
+We can pass our own instantiated UID utility to extentcatalog.Catalog.
+
+ >>> ext = extentcatalog.Extent(family=btrees_family)
+ >>> UIDSource = zope.app.intid.IntIds()
+ >>> cat = extentcatalog.Catalog(ext, UIDSource=UIDSource)
+ >>> cat.UIDSource is UIDSource
+ True
+ >>> obj = DummyContent(43, root)
+ >>> cat.index_doc(UIDSource.register(obj), obj)
+ >>> cat.updateIndex(DummyIndex())
+ >>> cat.updateIndexes()
+
[#cleanup]_
More information about the Checkins
mailing list