[Checkins] SVN: zope.app.catalog/trunk/ Functionality was moved to zope.catalog, so import from there.
Dan Korostelev
nadako at gmail.com
Sun Feb 1 11:20:36 EST 2009
Log message for revision 95862:
Functionality was moved to zope.catalog, so import from there.
Changed:
U zope.app.catalog/trunk/CHANGES.txt
U zope.app.catalog/trunk/README.txt
U zope.app.catalog/trunk/buildout.cfg
U zope.app.catalog/trunk/setup.py
D zope.app.catalog/trunk/src/zope/app/catalog/DEPENDENCIES.cfg
D zope.app.catalog/trunk/src/zope/app/catalog/README.txt
D zope.app.catalog/trunk/src/zope/app/catalog/SETUP.cfg
U zope.app.catalog/trunk/src/zope/app/catalog/apidoc.zcml
U zope.app.catalog/trunk/src/zope/app/catalog/attribute.py
U zope.app.catalog/trunk/src/zope/app/catalog/browser/README.txt
U zope.app.catalog/trunk/src/zope/app/catalog/browser/catalog.py
U zope.app.catalog/trunk/src/zope/app/catalog/browser/configure.zcml
U zope.app.catalog/trunk/src/zope/app/catalog/catalog.py
U zope.app.catalog/trunk/src/zope/app/catalog/classes.zcml
D zope.app.catalog/trunk/src/zope/app/catalog/event.txt
U zope.app.catalog/trunk/src/zope/app/catalog/field.py
U zope.app.catalog/trunk/src/zope/app/catalog/ftesting.zcml
U zope.app.catalog/trunk/src/zope/app/catalog/interfaces.py
UU zope.app.catalog/trunk/src/zope/app/catalog/keyword.py
U zope.app.catalog/trunk/src/zope/app/catalog/subscribers.zcml
U zope.app.catalog/trunk/src/zope/app/catalog/testing.py
D zope.app.catalog/trunk/src/zope/app/catalog/tests.py
U zope.app.catalog/trunk/src/zope/app/catalog/text.py
D zope.app.catalog/trunk/src/zope/app/catalog/zope.app.catalog-configure.zcml
-=-
Modified: zope.app.catalog/trunk/CHANGES.txt
===================================================================
--- zope.app.catalog/trunk/CHANGES.txt 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/CHANGES.txt 2009-02-01 16:20:36 UTC (rev 95862)
@@ -2,10 +2,12 @@
CHANGES
=======
-3.7.1 (unreleased)
+3.8.0 (unreleased)
------------------
-- ...
+- Move most of this package's code to new ``zope.catalog`` package,
+ leaving only ZMI-related views and backward-compatibility imports
+ here.
3.7.0 (2009-01-31)
------------------
Modified: zope.app.catalog/trunk/README.txt
===================================================================
--- zope.app.catalog/trunk/README.txt 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/README.txt 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,2 +1,2 @@
-Catalogs provide management of collections of related indexes with a basic
-search algorithm.
+This package provides ZMI-based browser management pages and menu items
+for zope.catalog - the cataloging and indexing framework for Zope 3.
Modified: zope.app.catalog/trunk/buildout.cfg
===================================================================
--- zope.app.catalog/trunk/buildout.cfg 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/buildout.cfg 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,5 +1,5 @@
[buildout]
-develop = . zope.container zope.app.container
+develop = . ../zope.catalog
parts = test
[test]
Modified: zope.app.catalog/trunk/setup.py
===================================================================
--- zope.app.catalog/trunk/setup.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/setup.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -22,20 +22,13 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name = 'zope.app.catalog',
- version = '3.7.1dev',
+ version = '3.8.0dev',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
- description='Zope Cataloging and Indexing Framework',
+ description='Management pages for Zope Catalog',
long_description=(
read('README.txt')
+ '\n\n' +
- 'Detailed Documentation\n'
- '**********************\n'
- + '\n\n' +
- read('src', 'zope', 'app', 'catalog', 'README.txt')
- + '\n\n' +
- read('src', 'zope', 'app', 'catalog', 'event.txt')
- + '\n\n' +
read('CHANGES.txt')
),
keywords = "zope3 catalog index",
@@ -57,6 +50,7 @@
extras_require = dict(
test=['zope.testing',
'zope.app.component',
+ 'zope.app.intid',
'zope.app.testing',
'zope.app.securitypolicy',
'zope.app.zcmlfiles',
@@ -64,17 +58,9 @@
]),
install_requires = [
'setuptools',
- 'ZODB3',
- 'zope.annotation',
- 'zope.app.intid',
- 'zope.component',
- 'zope.container',
- 'zope.index>=3.5.0',
- 'zope.interface',
- 'zope.lifecycleevent',
- 'zope.location',
- 'zope.schema',
- 'zope.traversing',
+ 'zope.catalog',
+ 'zope.app.publisher',
+ 'zope.app.form',
],
include_package_data = True,
zip_safe = False,
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/DEPENDENCIES.cfg
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/DEPENDENCIES.cfg 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/DEPENDENCIES.cfg 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,7 +0,0 @@
-zope.app.intid
-zope.index
-BTrees
-ZODB
-persistent
-transaction
-zope.interface
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/README.txt
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/README.txt 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/README.txt 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,360 +0,0 @@
-Catalogs
-========
-
-Catalogs provide management of collections of related indexes with a
-basic search algorithm. Let's look at an example:
-
- >>> from zope.app.catalog.catalog import Catalog
- >>> cat = Catalog()
-
-We can add catalog indexes to catalogs. A catalog index is, among
-other things, an attribute index. It indexes attributes of objects. To
-see how this works, we'll create a demonstration attribute index. Our
-attribute index will simply keep track of objects that have a given
-attribute value. The `catalog` package provides an attribute-index
-mix-in class that is meant to work with a base indexing class. First,
-we'll write the base index class:
-
- >>> import persistent, BTrees.OOBTree, BTrees.IFBTree, BTrees.IOBTree
- >>> import zope.interface, zope.index.interfaces
-
- >>> class BaseIndex(persistent.Persistent):
- ... zope.interface.implements(
- ... zope.index.interfaces.IInjection,
- ... zope.index.interfaces.IIndexSearch,
- ... zope.index.interfaces.IIndexSort,
- ... )
- ...
- ... def clear(self):
- ... self.forward = BTrees.OOBTree.OOBTree()
- ... self.backward = BTrees.IOBTree.IOBTree()
- ...
- ... __init__ = clear
- ...
- ... def index_doc(self, docid, value):
- ... if docid in self.backward:
- ... self.unindex_doc(docid)
- ... self.backward[docid] = value
- ...
- ... set = self.forward.get(value)
- ... if set is None:
- ... set = BTrees.IFBTree.IFTreeSet()
- ... self.forward[value] = set
- ... set.insert(docid)
- ...
- ... def unindex_doc(self, docid):
- ... value = self.backward.get(docid)
- ... if value is None:
- ... return
- ... self.forward[value].remove(docid)
- ... del self.backward[docid]
- ...
- ... def apply(self, value):
- ... set = self.forward.get(value)
- ... if set is None:
- ... set = BTrees.IFBTree.IFTreeSet()
- ... return set
- ...
- ... def sort(self, docids, limit=None, reverse=False):
- ... for i, docid in enumerate(sorted(docids, key=self.backward.get, reverse=reverse)):
- ... yield docid
- ... if limit and i >= (limit - 1):
- ... break
-
-The class implements `IInjection` to allow values to be indexed and
-unindexed and `IIndexSearch` to support searching via the `apply`
-method.
-
-Now, we can use the AttributeIndex mixin to make this an attribute
-index:
-
- >>> import zope.app.catalog.attribute
- >>> import zope.container.contained
- >>> import zope.app.catalog.interfaces
-
- >>> class Index(zope.app.catalog.attribute.AttributeIndex,
- ... BaseIndex,
- ... zope.container.contained.Contained,
- ... ):
- ... zope.interface.implements(zope.app.catalog.interfaces.ICatalogIndex)
-
-Unfortunately, because of the way we currently handle containment
-constraints, we have to provide `ICatalogIndex`, which extends
-`IContained`. We subclass `Contained` to get an implementation for
-`IContained`.
-
-Now let's add some of these indexes to our catalog. Let's create some
-indexes. First we'll define some interfaces providing data to index:
-
- >>> class IFavoriteColor(zope.interface.Interface):
- ... color = zope.interface.Attribute("Favorite color")
-
- >>> class IPerson(zope.interface.Interface):
- ... def age():
- ... """Return the person's age, in years"""
-
-We'll create color and age indexes:
-
- >>> cat['color'] = Index('color', IFavoriteColor)
- >>> cat['age'] = Index('age', IPerson, True)
- >>> cat['size'] = Index('sz')
-
-The indexes are created with:
-
-- the name of the of the attribute to index
-
-- the interface defining the attribute, and
-
-- a flag indicating whether the attribute should be called, which
- defaults to false.
-
-If an interface is provided, then we'll only be able to index an
-object if it can be adapted to the interface, otherwise, we'll simply
-try to get the attribute from the object. If the attribute isn't
-present, then we'll ignore the object.
-
-Now, let's create some objects and index them:
-
- >>> class Person:
- ... zope.interface.implements(IPerson)
- ... def __init__(self, age):
- ... self._age = age
- ... def age(self):
- ... return self._age
-
- >>> class Discriminating:
- ... zope.interface.implements(IFavoriteColor)
- ... def __init__(self, color):
- ... self.color = color
-
- >>> class DiscriminatingPerson(Discriminating, Person):
- ... def __init__(self, age, color):
- ... Discriminating.__init__(self, color)
- ... Person.__init__(self, age)
-
- >>> class Whatever:
- ... def __init__(self, **kw):
- ... self.__dict__.update(kw)
-
- >>> o1 = Person(10)
- >>> o2 = DiscriminatingPerson(20, 'red')
- >>> o3 = Discriminating('blue')
- >>> o4 = Whatever(a=10, c='blue', sz=5)
- >>> o5 = Whatever(a=20, c='red', sz=6)
- >>> o6 = DiscriminatingPerson(10, 'blue')
-
- >>> cat.index_doc(1, o1)
- >>> cat.index_doc(2, o2)
- >>> cat.index_doc(3, o3)
- >>> cat.index_doc(4, o4)
- >>> cat.index_doc(5, o5)
- >>> cat.index_doc(6, o6)
-
-We search by providing query mapping objects that have a key for every
-index we want to use:
-
- >>> list(cat.apply({'age': 10}))
- [1, 6]
- >>> list(cat.apply({'age': 10, 'color': 'blue'}))
- [6]
- >>> list(cat.apply({'age': 10, 'color': 'blue', 'size': 5}))
- []
- >>> list(cat.apply({'size': 5}))
- [4]
-
-We can unindex objects:
-
- >>> cat.unindex_doc(4)
- >>> list(cat.apply({'size': 5}))
- []
-
-and reindex objects:
-
- >>> o5.sz = 5
- >>> cat.index_doc(5, o5)
- >>> list(cat.apply({'size': 5}))
- [5]
-
-If we clear the catalog, we'll clear all of the indexes:
-
- >>> cat.clear()
- >>> [len(index.forward) for index in cat.values()]
- [0, 0, 0]
-
-Note that you don't have to use the catalog's search methods. You can
-access its indexes directly, since the catalog is a mapping:
-
- >>> [(name, cat[name].field_name) for name in cat]
- [(u'age', 'age'), (u'color', 'color'), (u'size', 'sz')]
-
-Catalogs work with int-id utilities, which are responsible for
-maintaining id <-> object mappings. To see how this works, we'll
-create a utility to work with our catalog:
-
- >>> import zope.app.intid.interfaces
- >>> class Ids:
- ... zope.interface.implements(zope.app.intid.interfaces.IIntIds)
- ... def __init__(self, data):
- ... self.data = data
- ... def getObject(self, id):
- ... return self.data[id]
- ... def __iter__(self):
- ... return self.data.iterkeys()
- >>> ids = Ids({1: o1, 2: o2, 3: o3, 4: o4, 5: o5, 6: o6})
-
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(zope.app.intid.interfaces.IIntIds, ids)
-
-With this utility in place, catalogs can recompute indexes:
-
- >>> cat.updateIndex(cat['size'])
- >>> list(cat.apply({'size': 5}))
- [4, 5]
-
-Of course, that only updates *that* index:
-
- >>> list(cat.apply({'age': 10}))
- []
-
-We can update all of the indexes:
-
- >>> cat.updateIndexes()
- >>> list(cat.apply({'age': 10}))
- [1, 6]
- >>> list(cat.apply({'color': 'red'}))
- [2]
-
-
-There's an alternate search interface that returns "result sets".
-Result sets provide access to objects, rather than object ids:
-
- >>> result = cat.searchResults(size=5)
- >>> len(result)
- 2
- >>> list(result) == [o4, o5]
- True
-
-The searchResults method also provides a way to sort, limit and reverse
-results.
-
-When not using sorting, limiting and reversing are done by simple slicing
-and list reversing.
-
- >>> list(cat.searchResults(size=5, _reverse=True)) == [o5, o4]
- True
-
- >>> list(cat.searchResults(size=5, _limit=1)) == [o4]
- True
-
- >>> list(cat.searchResults(size=5, _limit=1, _reverse=True)) == [o5]
- True
-
-However, when using sorting by index, the limit and reverse parameters
-are passed to the index ``sort`` method so it can do it efficiently.
-
-Let's index more objects to work with:
-
- >>> o7 = DiscriminatingPerson(7, 'blue')
- >>> o8 = DiscriminatingPerson(3, 'blue')
- >>> o9 = DiscriminatingPerson(14, 'blue')
- >>> o10 = DiscriminatingPerson(1, 'blue')
- >>> ids.data.update({7: o7, 8: o8, 9: o9, 10: o10})
- >>> cat.index_doc(7, o7)
- >>> cat.index_doc(8, o8)
- >>> cat.index_doc(9, o9)
- >>> cat.index_doc(10, o10)
-
-Now we can search all people who like blue, ordered by age:
-
- >>> results = list(cat.searchResults(color='blue', _sort_index='age'))
- >>> results == [o3, o10, o8, o7, o6, o9]
- True
-
- >>> results = list(cat.searchResults(color='blue', _sort_index='age', _limit=3))
- >>> results == [o3, o10, o8]
- True
-
- >>> results = list(cat.searchResults(color='blue', _sort_index='age', _reverse=True))
- >>> results == [o9, o6, o7, o8, o10, o3]
- True
-
- >>> results = list(cat.searchResults(color='blue', _sort_index='age', _reverse=True, _limit=4))
- >>> results == [o9, o6, o7, o8]
- True
-
-The index example we looked at didn't provide document scores. Simple
-indexes normally don't, but more complex indexes might give results
-scores, according to how closely a document matches a query. Let's
-create a new index, a "keyword index" that indexes sequences of
-values:
-
- >>> class BaseKeywordIndex(persistent.Persistent):
- ... zope.interface.implements(
- ... zope.index.interfaces.IInjection,
- ... zope.index.interfaces.IIndexSearch,
- ... )
- ...
- ... def clear(self):
- ... self.forward = BTrees.OOBTree.OOBTree()
- ... self.backward = BTrees.IOBTree.IOBTree()
- ...
- ... __init__ = clear
- ...
- ... def index_doc(self, docid, values):
- ... if docid in self.backward:
- ... self.unindex_doc(docid)
- ... self.backward[docid] = values
- ...
- ... for value in values:
- ... set = self.forward.get(value)
- ... if set is None:
- ... set = BTrees.IFBTree.IFTreeSet()
- ... self.forward[value] = set
- ... set.insert(docid)
- ...
- ... def unindex_doc(self, docid):
- ... values = self.backward.get(docid)
- ... if values is None:
- ... return
- ... for value in values:
- ... self.forward[value].remove(docid)
- ... del self.backward[docid]
- ...
- ... def apply(self, values):
- ... result = BTrees.IFBTree.IFBucket()
- ... for value in values:
- ... set = self.forward.get(value)
- ... if set is not None:
- ... _, result = BTrees.IFBTree.weightedUnion(result, set)
- ... return result
-
- >>> class KeywordIndex(zope.app.catalog.attribute.AttributeIndex,
- ... BaseKeywordIndex,
- ... zope.container.contained.Contained,
- ... ):
- ... zope.interface.implements(zope.app.catalog.interfaces.ICatalogIndex)
-
-Now, we'll add a hobbies index:
-
- >>> cat['hobbies'] = KeywordIndex('hobbies')
- >>> o1.hobbies = 'camping', 'music'
- >>> o2.hobbies = 'hacking', 'sailing'
- >>> o3.hobbies = 'music', 'camping', 'sailing'
- >>> o6.hobbies = 'cooking', 'dancing'
- >>> cat.updateIndexes()
-
-When we apply the catalog:
-
- >>> cat.apply({'hobbies': ['music', 'camping', 'sailing']})
- BTrees.IFBTree.IFBucket([(1, 2.0), (2, 1.0), (3, 3.0)])
-
-We found objects 1-3, because they each contained at least some of the
-words in the query. The scores represent the number of words that
-matched. If we also include age:
-
- >>> cat.apply({'hobbies': ['music', 'camping', 'sailing'], 'age': 10})
- BTrees.IFBTree.IFBucket([(1, 3.0)])
-
-The score increased because we used an additional index. If an index
-doesn't provide scores, scores of 1.0 are assumed.
-
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/SETUP.cfg
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/SETUP.cfg 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/SETUP.cfg 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,3 +0,0 @@
-<data-files zopeskel/etc/package-includes>
- *-configure.zcml
-</data-files>
Modified: zope.app.catalog/trunk/src/zope/app/catalog/apidoc.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/apidoc.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/apidoc.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,36 +1,3 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:apidoc="http://namespaces.zope.org/apidoc"
- xmlns:zcml="http://namespaces.zope.org/zcml"
- zcml:condition="have apidoc"
- i18n_domain="zope"
- >
-
- <apidoc:bookchapter
- id="indexcatalog"
- title="Indexes and Catalogs"
- />
- <apidoc:bookchapter
- id="catalog"
- title="Catalog"
- doc_path="README.txt"
- parent="indexcatalog"
- />
-
- <configure package="zope.index">
- <apidoc:bookchapter
- id="fieldindex"
- title="Field Indexes"
- doc_path="field/README.txt"
- parent="indexcatalog"
- />
- <apidoc:bookchapter
- id="testindex"
- title="Text Indexes"
- doc_path="text/textindex.txt"
- parent="indexcatalog"
- />
- </configure>
-
+<configure xmlns="http://namespaces.zope.org/zope">
+ <include package="zope.catalog" file="apidoc.zcml" />
</configure>
Modified: zope.app.catalog/trunk/src/zope/app/catalog/attribute.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/attribute.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/attribute.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,130 +15,4 @@
$Id$
"""
-__docformat__ = 'restructuredtext'
-
-import zope.interface
-from zope.app.catalog.interfaces import IAttributeIndex
-
-class AttributeIndex(object):
- """Index interface-defined attributes
-
- Mixin for indexing a particular attribute of an object after
- first adapting the object to be indexed to an interface.
-
- The class is meant to be mixed with a base class that defines an
- index_doc method:
-
- >>> class BaseIndex(object):
- ... def __init__(self):
- ... self.data = []
- ... def index_doc(self, id, value):
- ... self.data.append((id, value))
-
- The class does two things. The first is to get a named field
- from an object:
-
- >>> class Data:
- ... def __init__(self, v):
- ... self.x = v
-
- >>> class Index(AttributeIndex, BaseIndex):
- ... pass
-
- >>> index = Index('x')
- >>> index.index_doc(11, Data(1))
- >>> index.index_doc(22, Data(2))
- >>> index.data
- [(11, 1), (22, 2)]
-
- A method can be indexed:
-
- >>> Data.z = lambda self: self.x + 20
- >>> index = Index('z', field_callable=True)
- >>> index.index_doc(11, Data(1))
- >>> index.index_doc(22, Data(2))
- >>> index.data
- [(11, 21), (22, 22)]
-
- But you'll get an error if you try to index a method without
- setting field_callable:
-
- >>> index = Index('z')
- >>> index.index_doc(11, Data(1))
-
- The class can also adapt an object to an interface:
-
- >>> from zope.interface import Interface
- >>> class I(Interface):
- ... pass
-
- >>> class Data:
- ... def __init__(self, v):
- ... self.x = v
- ... def __conform__(self, iface):
- ... if iface is I:
- ... return Data2(self.x)
-
- >>> class Data2:
- ... def __init__(self, v):
- ... self.y = v*v
-
- >>> index = Index('y', I)
- >>> index.index_doc(11, Data(3))
- >>> index.index_doc(22, Data(2))
- >>> index.data
- [(11, 9), (22, 4)]
-
- When you define an index class, you can define a default
- interface and/or a default interface:
-
- >>> class Index(AttributeIndex, BaseIndex):
- ... default_interface = I
- ... default_field_name = 'y'
-
- >>> index = Index()
- >>> index.index_doc(11, Data(3))
- >>> index.index_doc(22, Data(2))
- >>> index.data
- [(11, 9), (22, 4)]
-
- """
-
- zope.interface.implements(IAttributeIndex)
-
- default_field_name = None
- default_interface = None
-
- def __init__(self, field_name=None, interface=None, field_callable=False,
- *args, **kwargs):
- super(AttributeIndex, self).__init__(*args, **kwargs)
- if field_name is None and self.default_field_name is None:
- raise ValueError("Must pass a field_name")
- if field_name is None:
- self.field_name = self.default_field_name
- else:
- self.field_name = field_name
- if interface is None:
- self.interface = self.default_interface
- else:
- self.interface = interface
- self.field_callable = field_callable
-
- def index_doc(self, docid, object):
- if self.interface is not None:
- object = self.interface(object, None)
- if object is None:
- return None
-
- value = getattr(object, self.field_name, None)
-
- if value is not None and self.field_callable:
- #do not eat the exception raised below
- value = value()
-
- if value is None:
- #unindex the previous value!
- super(AttributeIndex, self).unindex_doc(docid)
- return None
-
- return super(AttributeIndex, self).index_doc(docid, value)
+from zope.catalog.attribute import AttributeIndex # BBB
Modified: zope.app.catalog/trunk/src/zope/app/catalog/browser/README.txt
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/browser/README.txt 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/browser/README.txt 2009-02-01 16:20:36 UTC (rev 95862)
@@ -23,7 +23,7 @@
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/++etc++site/default/@@+
...
- ... type_name=BrowserAdd__zope.app.intid.IntIds&id=&add=+Add+""",
+ ... type_name=BrowserAdd__zope.intid.IntIds&id=&add=+Add+""",
... handle_errors=False)
HTTP/1.1 303 ...
@@ -42,7 +42,7 @@
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
... Content-Disposition: form-data; name="field.provided"
...
- ... zope.app.intid.interfaces.IIntIds
+ ... zope.intid.interfaces.IIntIds
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
... Content-Disposition: form-data; name="field.provided-empty-marker"
...
@@ -86,7 +86,7 @@
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/++etc++site/default/@@+
...
- ... type_name=BrowserAdd__zope.app.catalog.catalog.Catalog&id=&add=+Add+""")
+ ... type_name=BrowserAdd__zope.catalog.catalog.Catalog&id=&add=+Add+""")
HTTP/1.1 303 ...
and register it:
@@ -104,7 +104,7 @@
... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
... Content-Disposition: form-data; name="field.provided"
...
- ... zope.app.catalog.interfaces.ICatalog
+ ... zope.catalog.interfaces.ICatalog
... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
... Content-Disposition: form-data; name="field.provided-empty-marker"
...
@@ -354,13 +354,13 @@
We'll make our root folder the site (this would normally be done by
the publisher):
- >>> from zope.app.component.hooks import setSite
+ >>> from zope.site.hooks import setSite
>>> setSite(root)
Now, we'll get the catalog:
>>> import zope.component
- >>> from zope.app.catalog.interfaces import ICatalog
+ >>> from zope.catalog.interfaces import ICatalog
>>> catalog = zope.component.getUtility(ICatalog)
And search it to find the names of all of the documents that contain
Modified: zope.app.catalog/trunk/src/zope/app/catalog/browser/catalog.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/browser/catalog.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/browser/catalog.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,7 +15,7 @@
$Id$
"""
-from zope.app.catalog.interfaces import ICatalog
+from zope.catalog.interfaces import ICatalog
class Advanced:
"Provides a user interface for configuring a catalog"
Modified: zope.app.catalog/trunk/src/zope/app/catalog/browser/configure.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/browser/configure.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/browser/configure.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,32 +1,28 @@
-<zope:configure
- xmlns:zope="http://namespaces.zope.org/zope"
- xmlns="http://namespaces.zope.org/browser"
- i18n_domain="zope"
- >
+<configure xmlns="http://namespaces.zope.org/browser" i18n_domain="zope">
<!-- Allow a catalog to be added to content space -->
<addMenuItem
title="Catalog"
description="A Catalog allows indexing and searching of objects"
- class="zope.app.catalog.catalog.Catalog"
+ class="zope.catalog.catalog.Catalog"
permission="zope.ManageServices"
/>
<icon
name="zmi_icon"
- for="zope.app.catalog.interfaces.ICatalog"
+ for="zope.catalog.interfaces.ICatalog"
file="catalog_icon.gif"
/>
<containerViews
- for="..interfaces.ICatalog"
+ for="zope.catalog.interfaces.ICatalog"
contents="zope.ManageServices"
index="zope.ManageServices"
add="zope.ManageServices"
/>
<pages
- for="..interfaces.ICatalog"
+ for="zope.catalog.interfaces.ICatalog"
class=".catalog.Advanced"
permission="zope.ManageContent">
@@ -40,9 +36,9 @@
<addform
name="AddFieldIndex"
label="Add a field index"
- schema="..interfaces.IAttributeIndex"
+ schema="zope.catalog.interfaces.IAttributeIndex"
permission="zope.ManageServices"
- content_factory="..field.FieldIndex"
+ content_factory="zope.catalog.field.FieldIndex"
arguments="field_name"
keyword_arguments="interface field_callable"
/>
@@ -50,14 +46,14 @@
<addMenuItem
title="Field Index"
description="Index items based on an orderable field value"
- class="..field.FieldIndex"
+ class="zope.catalog.field.FieldIndex"
permission="zope.ManageServices"
view="AddFieldIndex"
/>
<schemadisplay
name="index.html"
- schema="..field.IFieldIndex"
+ schema="zope.catalog.field.IFieldIndex"
label="Field Index"
fields="interface field_name field_callable"
permission="zope.ManageServices"
@@ -67,9 +63,9 @@
<addform
name="AddKeywordIndex"
label="Add a keyword index"
- schema="..interfaces.IAttributeIndex"
+ schema="zope.catalog.interfaces.IAttributeIndex"
permission="zope.ManageServices"
- content_factory="..keyword.KeywordIndex"
+ content_factory="zope.catalog.keyword.KeywordIndex"
arguments="field_name"
keyword_arguments="interface field_callable"
/>
@@ -77,17 +73,17 @@
<addMenuItem
title="Keyword Index"
description="Index items based on sequence of keywords"
- class="..keyword.KeywordIndex"
+ class="zope.catalog.keyword.KeywordIndex"
permission="zope.ManageServices"
view="AddKeywordIndex"
/>
<addform
name="AddCaseInsensitiveKeywordIndex"
- label="Add a keyword index (case-omsensitive)"
- schema="..interfaces.IAttributeIndex"
+ label="Add a keyword index (case-insensitive)"
+ schema="zope.catalog.interfaces.IAttributeIndex"
permission="zope.ManageServices"
- content_factory="..keyword.CaseInsensitiveKeywordIndex"
+ content_factory="zope.catalog.keyword.CaseInsensitiveKeywordIndex"
arguments="field_name"
keyword_arguments="interface field_callable"
/>
@@ -95,14 +91,14 @@
<addMenuItem
title="Keyword Index (case-insensitive)"
description="Index items based on sequence of keywords"
- class="..keyword.CaseInsensitiveKeywordIndex"
+ class="zope.catalog.keyword.CaseInsensitiveKeywordIndex"
permission="zope.ManageServices"
view="AddCaseInsensitiveKeywordIndex"
/>
<schemadisplay
name="index.html"
- schema="..keyword.IKeywordIndex"
+ schema="zope.catalog.keyword.IKeywordIndex"
label="Keyword Index"
fields="interface field_name field_callable"
permission="zope.ManageServices"
@@ -112,19 +108,18 @@
<addform
name="AddTextIndex"
label="Add a text index"
- schema="..text.ITextIndex"
+ schema="zope.catalog.text.ITextIndex"
fields="interface field_name field_callable"
permission="zope.ManageServices"
- content_factory="..text.TextIndex"
+ content_factory="zope.catalog.text.TextIndex"
arguments="field_name"
keyword_arguments="interface field_callable"
/>
<addMenuItem
title="Text Index"
- description="Index items based on multi-value fields with
- orderable values"
- class="..text.TextIndex"
+ description="Index items by their text values"
+ class="zope.catalog.text.TextIndex"
permission="zope.ManageServices"
view="AddTextIndex"
/>
@@ -132,10 +127,10 @@
<schemadisplay
name="index.html"
fields="interface field_name field_callable"
- schema="..text.ITextIndex"
+ schema="zope.catalog.text.ITextIndex"
label="Text Index"
permission="zope.ManageServices"
menu="zmi_views" title="Configuration"
/>
-</zope:configure>
+</configure>
Modified: zope.app.catalog/trunk/src/zope/app/catalog/catalog.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/catalog.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/catalog.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,192 +15,13 @@
$Id$
"""
-__docformat__ = 'restructuredtext'
-import BTrees
-
-import zope.index.interfaces
-from zope import component
-from zope.interface import implements
-from zope.annotation.interfaces import IAttributeAnnotatable
-
-from zope.container.interfaces import IContainer
-from zope.container.btree import BTreeContainer
-from zope.app.catalog.interfaces import ICatalog, INoAutoIndex, INoAutoReindex
-from zope.app.intid.interfaces import IIntIds
-from zope.traversing.interfaces import IPhysicallyLocatable
-from zope.location import location
-
-
-class ResultSet:
- """Lazily accessed set of objects."""
-
- def __init__(self, uids, uidutil):
- self.uids = uids
- self.uidutil = uidutil
-
- def __len__(self):
- return len(self.uids)
-
- def __iter__(self):
- for uid in self.uids:
- obj = self.uidutil.getObject(uid)
- yield obj
-
-
-class Catalog(BTreeContainer):
-
- implements(ICatalog,
- IContainer,
- IAttributeAnnotatable,
- zope.index.interfaces.IIndexSearch,
- )
-
- family = BTrees.family32
-
- def __init__(self, family=None):
- super(Catalog, self).__init__()
- if family is not None:
- self.family = family
-
- def clear(self):
- for index in self.values():
- index.clear()
-
- def index_doc(self, docid, texts):
- """Register the data in indexes of this catalog."""
- for index in self.values():
- index.index_doc(docid, texts)
-
- def unindex_doc(self, docid):
- """Unregister the data from indexes of this catalog."""
- for index in self.values():
- index.unindex_doc(docid)
-
- def _visitSublocations(self) :
- """Restricts the access to the objects that live within
- the nearest site if the catalog itself is locatable.
- """
- uidutil = None
- locatable = IPhysicallyLocatable(self, None)
- if locatable is not None :
- site = locatable.getNearestSite()
- sm = site.getSiteManager()
- uidutil = sm.queryUtility(IIntIds)
- if uidutil not in [c.component for c in sm.registeredUtilities()]:
- # we do not have a local inits utility
- uidutil = component.getUtility(IIntIds, context=self)
- for uid in uidutil:
- obj = uidutil.getObject(uid)
- if location.inside(obj, site) :
- yield uid, obj
- return
- if uidutil is None:
- uidutil = component.getUtility(IIntIds)
- for uid in uidutil:
- yield uid, uidutil.getObject(uid)
-
- def updateIndex(self, index):
- for uid, obj in self._visitSublocations() :
- index.index_doc(uid, obj)
-
- def updateIndexes(self):
- for uid, obj in self._visitSublocations() :
- for index in self.values():
- index.index_doc(uid, obj)
-
- def apply(self, query):
- results = []
- for index_name, index_query in query.items():
- index = self[index_name]
- r = index.apply(index_query)
- if r is None:
- continue
- if not r:
- # empty results
- return r
- results.append((len(r), r))
-
- if not results:
- # no applicable indexes, so catalog was not applicable
- return None
-
- results.sort() # order from smallest to largest
-
- _, result = results.pop(0)
- for _, r in results:
- _, result = self.family.IF.weightedIntersection(result, r)
-
- return result
-
- def searchResults(self, **searchterms):
- sort_index = searchterms.pop('_sort_index', None)
- limit = searchterms.pop('_limit', None)
- reverse = searchterms.pop('_reverse', False)
- results = self.apply(searchterms)
- if results is not None:
- if sort_index is not None:
- index = self[sort_index]
- if not zope.index.interfaces.IIndexSort.providedBy(index):
- raise ValueError('Index %s does not support sorting.' % sort_index)
- results = list(index.sort(results, limit=limit, reverse=reverse))
- else:
- if reverse or limit:
- results = list(results)
- if reverse:
- results.reverse()
- if limit:
- del results[limit:]
- uidutil = component.getUtility(IIntIds)
- results = ResultSet(results, uidutil)
- return results
-
-def indexAdded(index, event):
- """When an index is added to a catalog, we have to index existing objects
-
- When an index is added, we tell it's parent to index it:
-
- >>> class FauxCatalog:
- ... def updateIndex(self, index):
- ... self.updated = index
-
- >>> class FauxIndex:
- ... pass
-
- >>> index = FauxIndex()
- >>> index.__parent__ = FauxCatalog()
-
- >>> indexAdded(index, None)
- >>> index.__parent__.updated is index
- True
- """
- index.__parent__.updateIndex(index)
-
-def indexDocSubscriber(event):
- """A subscriber to IntIdAddedEvent"""
- ob = event.object
- if INoAutoIndex.providedBy(ob):
- return
- for cat in component.getAllUtilitiesRegisteredFor(ICatalog, context=ob):
- id = component.getUtility(IIntIds, context=cat).getId(ob)
- cat.index_doc(id, ob)
-
-
-def reindexDocSubscriber(event):
- """A subscriber to ObjectModifiedEvent"""
- ob = event.object
- if INoAutoReindex.providedBy(ob):
- return
- for cat in component.getAllUtilitiesRegisteredFor(ICatalog, context=ob):
- id = component.getUtility(IIntIds, context=cat).queryId(ob)
- if id is not None:
- cat.index_doc(id, ob)
-
-
-def unindexDocSubscriber(event):
- """A subscriber to IntIdRemovedEvent"""
- ob = event.object
- for cat in component.getAllUtilitiesRegisteredFor(ICatalog, context=ob):
- id = component.getUtility(IIntIds, context=cat).queryId(ob)
- if id is not None:
- cat.unindex_doc(id)
+# BBB
+from zope.catalog import (
+ ResultSet,
+ Catalog,
+ indexAdded,
+ indexDocSubscriber,
+ reindexDocSubscriber,
+ unindexDocSubscriber,
+)
Modified: zope.app.catalog/trunk/src/zope/app/catalog/classes.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/classes.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/classes.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,70 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- >
+<configure xmlns="http://namespaces.zope.org/zope">
- <class class=".catalog.Catalog">
- <factory
- id="zope.app.catalog"
- />
- <implements
- interface="zope.annotation.interfaces.IAttributeAnnotatable"
- />
- <require
- interface="zope.app.catalog.interfaces.ICatalogQuery"
- permission="zope.Public"
- />
- <require
- interface="zope.app.catalog.interfaces.ICatalogEdit"
- permission="zope.ManageServices"
- />
- <require
- interface="zope.container.interfaces.IContainer"
- permission="zope.ManageServices"
- />
- </class>
+ <include package="zope.catalog" file="classes.zcml" />
- <class class=".catalog.ResultSet">
- <require
- attributes="__iter__ __len__"
- permission="zope.Public"
- />
- </class>
-
- <class class=".field.FieldIndex">
- <require
- permission="zope.ManageServices"
- interface=".interfaces.IAttributeIndex
- zope.index.interfaces.IStatistics
- "
- set_schema=".interfaces.IAttributeIndex"
- />
- </class>
-
- <class class=".keyword.KeywordIndex">
- <require
- permission="zope.ManageServices"
- interface=".interfaces.IAttributeIndex
- zope.index.interfaces.IStatistics"
- set_schema=".interfaces.IAttributeIndex"
- />
- </class>
-
- <class class=".keyword.CaseInsensitiveKeywordIndex">
- <require like_class=".keyword.KeywordIndex" />
- </class>
-
- <class class=".text.TextIndex">
- <require
- permission="zope.ManageServices"
- interface=".interfaces.IAttributeIndex
- zope.index.interfaces.IStatistics
- "
- set_schema=".interfaces.IAttributeIndex"
- />
- </class>
-
- <interface interface="zope.index.text.interfaces.ISearchableText" />
-
</configure>
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/event.txt
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/event.txt 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/event.txt 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,86 +0,0 @@
-==============================
-Automatic indexing with events
-==============================
-
-In order to automatically keep the catalog up-to-date any objects that
-are added to a intid utility are indexed automatically. Also when an
-object gets modified it is reindexed by listening to IObjectModified
-events.
-
-Let us create a fake catalog to demonstrate this behaviour. We only
-need to implement the index_doc method for this test.
-
- >>> from zope.app.catalog.interfaces import ICatalog
- >>> from zope import interface, component
- >>> class FakeCatalog(object):
- ... indexed = []
- ... interface.implements(ICatalog)
- ... def index_doc(self, docid, obj):
- ... self.indexed.append((docid, obj))
- >>> cat = FakeCatalog()
- >>> component.provideUtility(cat)
-
-We also need an intid util and a keyreference adapter.
-
- >>> from zope.app.intid import IntIds
- >>> from zope.app.intid.interfaces import IIntIds
- >>> intids = IntIds()
- >>> component.provideUtility(intids, IIntIds)
- >>> from zope.app.keyreference.testing import SimpleKeyReference
- >>> component.provideAdapter(SimpleKeyReference)
-
- >>> from zope.container.contained import Contained
- >>> class Dummy(Contained):
- ... def __init__(self, name):
- ... self.__name__ = name
- ... def __repr__(self):
- ... return '<Dummy %r>' % self.__name__
-
-We have a subscriber to IIntidAddedEvent.
-
- >>> from zope.app.catalog import catalog
- >>> from zope.app.intid.interfaces import IntIdAddedEvent
- >>> d1 = Dummy(u'one')
- >>> id1 = intids.register(d1)
- >>> catalog.indexDocSubscriber(IntIdAddedEvent(d1, None))
-
-Now we have indexed the object.
-
- >>> cat.indexed.pop()
- (..., <Dummy u'one'>)
-
-When an object is modified an objectmodified event should be fired by
-the application. Here is the handler for such an event.
-
- >>> from zope.lifecycleevent import ObjectModifiedEvent
- >>> catalog.reindexDocSubscriber(ObjectModifiedEvent(d1))
- >>> len(cat.indexed)
- 1
- >>> cat.indexed.pop()
- (..., <Dummy u'one'>)
-
-Preventing automatic indexing
-=============================
-
-Sometimes it is not accurate to automatically index an object. For
-example when a lot of indexes are in the catalog and only
-specific indexes needs to be updated. There are marker interfaces to
-achieve this.
-
- >>> from zope.app.catalog.interfaces import INoAutoIndex
-
-If an object provides this interface it is not automatically indexed.
-
- >>> interface.alsoProvides(d1, INoAutoIndex)
- >>> catalog.indexDocSubscriber(IntIdAddedEvent(d1, None))
- >>> len(cat.indexed)
- 0
-
- >>> from zope.app.catalog.interfaces import INoAutoReindex
-
-If an object provides this interface it is not automatically reindexed.
-
- >>> interface.alsoProvides(d1, INoAutoReindex)
- >>> catalog.reindexDocSubscriber(ObjectModifiedEvent(d1))
- >>> len(cat.indexed)
- 0
Modified: zope.app.catalog/trunk/src/zope/app/catalog/field.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/field.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/field.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,22 +15,5 @@
$Id$
"""
-import zope.index.field
-import zope.interface
-import zope.container.contained
-import zope.app.catalog.attribute
-import zope.app.catalog.interfaces
-
-class IFieldIndex(zope.app.catalog.interfaces.IAttributeIndex,
- zope.app.catalog.interfaces.ICatalogIndex):
- """Interface-based catalog field index
- """
-
-class FieldIndex(zope.app.catalog.attribute.AttributeIndex,
- zope.index.field.FieldIndex,
- zope.container.contained.Contained):
-
- zope.interface.implements(IFieldIndex)
-
-
+from zope.catalog.field import IFieldIndex, FieldIndex # BBB
Modified: zope.app.catalog/trunk/src/zope/app/catalog/ftesting.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/ftesting.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/ftesting.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -7,14 +7,13 @@
<!-- This file is the equivalent of site.zcml and it is -->
<!-- used for functional testing setup -->
- <include package="zope.app.securitypolicy" file="meta.zcml" />
+ <include package="zope.securitypolicy" file="meta.zcml" />
<include package="zope.app.zcmlfiles" />
- <include package="zope.formlib" />
<include package="zope.app.zptpage"/>
<include package="zope.app.authentication" />
- <include package="zope.app.keyreference" />
+ <include package="zope.keyreference" />
<include package="zope.app.intid" />
<include package="zope.app.catalog"/>
<include package="zope.app.zptpage.textindex" />
Modified: zope.app.catalog/trunk/src/zope/app/catalog/interfaces.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/interfaces.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/interfaces.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -16,90 +16,13 @@
$Id$
"""
-import zope.index.interfaces
-import zope.interface
-import zope.schema
-import zope.container.interfaces
-import zope.container.constraints
-
-from zope.i18nmessageid import ZopeMessageFactory as _
-
-class ICatalogQuery(zope.interface.Interface):
- """Provides Catalog Queries."""
-
- def searchResults(**kw):
- """Search on the given indexes.
-
- Keyword arguments dictionary keys
- are index names and values are queries
- for these indexes.
-
- Keyword arguments has some special names,
- used by the catalog itself:
-
- * _sort_index - The name of index to sort
- results with. This index must implement
- zope.index.interfaces.IIndexSort.
- * _limit - Limit result set by this number,
- useful when used with sorting.
- * _reverse - Reverse result set, also
- useful with sorting.
-
- """
-
-
-class ICatalogEdit(zope.index.interfaces.IInjection):
- """Allows one to manipulate the Catalog information."""
-
- def updateIndexes():
- """Reindex all objects."""
-
-
-class ICatalogIndex(zope.index.interfaces.IInjection,
- zope.index.interfaces.IIndexSearch,
- ):
- """An index to be used in a catalog
- """
- __parent__ = zope.schema.Field()
-
-
-class ICatalog(ICatalogQuery, ICatalogEdit,
- zope.container.interfaces.IContainer):
- """Marker to describe a catalog in content space."""
-
- zope.container.constraints.contains(ICatalogIndex)
-
-ICatalogIndex['__parent__'].constraint = (
- zope.container.constraints.ContainerTypesConstraint(ICatalog))
-
-class IAttributeIndex(zope.interface.Interface):
- """I index objects by first adapting them to an interface, then
- retrieving a field on the adapted object.
- """
-
- interface = zope.schema.Choice(
- title=_(u"Interface"),
- description=_(u"Objects will be adapted to this interface"),
- vocabulary="Interfaces",
- required=False,
- )
-
- field_name = zope.schema.BytesLine(
- title=_(u"Field Name"),
- description=_(u"Name of the field to index"),
- )
-
- field_callable = zope.schema.Bool(
- title=_(u"Field Callable"),
- description=_(u"If true, then the field should be called to get the "
- u"value to be indexed"),
- )
-
-
-class INoAutoIndex(zope.interface.Interface):
-
- """Marker for objects that should not be automatically indexed"""
-
-class INoAutoReindex(zope.interface.Interface):
-
- """Marker for objects that should not be automatically reindexed"""
+# BBB
+from zope.catalog.interfaces import (
+ ICatalogQuery,
+ ICatalogEdit,
+ ICatalogIndex,
+ ICatalog,
+ IAttributeIndex,
+ INoAutoIndex,
+ INoAutoReindex,
+)
Modified: zope.app.catalog/trunk/src/zope/app/catalog/keyword.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/keyword.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/keyword.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,25 +15,10 @@
$Id:$
"""
-import zope.index.keyword
-import zope.interface
-import zope.container.contained
-import zope.app.catalog.attribute
-import zope.app.catalog.interfaces
-
-class IKeywordIndex(zope.app.catalog.interfaces.IAttributeIndex,
- zope.app.catalog.interfaces.ICatalogIndex):
- """Interface-based catalog keyword index"""
-
-class KeywordIndex(zope.app.catalog.attribute.AttributeIndex,
- zope.index.keyword.KeywordIndex,
- zope.container.contained.Contained):
-
- zope.interface.implements(IKeywordIndex)
-
-class CaseInsensitiveKeywordIndex(zope.app.catalog.attribute.AttributeIndex,
- zope.index.keyword.CaseInsensitiveKeywordIndex,
- zope.container.contained.Contained):
-
- zope.interface.implements(IKeywordIndex)
+# BBB
+from zope.catalog.keyword import (
+ IKeywordIndex,
+ KeywordIndex,
+ CaseInsensitiveKeywordIndex
+)
Property changes on: zope.app.catalog/trunk/src/zope/app/catalog/keyword.py
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: zope.app.catalog/trunk/src/zope/app/catalog/subscribers.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/subscribers.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/subscribers.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,28 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- >
+<configure xmlns="http://namespaces.zope.org/zope">
- <subscriber
- handler=".catalog.indexAdded"
- for=".interfaces.ICatalogIndex
- zope.container.interfaces.IObjectAddedEvent"
- />
+ <include package="zope.catalog" file="subscribers.zcml" />
- <subscriber
- handler=".catalog.indexDocSubscriber"
- for="zope.app.intid.interfaces.IIntIdAddedEvent"
- />
-
- <subscriber
- handler=".catalog.reindexDocSubscriber"
- for="zope.lifecycleevent.interfaces.IObjectModifiedEvent"
- />
-
- <subscriber
- handler=".catalog.unindexDocSubscriber"
- for="zope.app.intid.interfaces.IIntIdRemovedEvent"
- />
-
</configure>
Modified: zope.app.catalog/trunk/src/zope/app/catalog/testing.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/testing.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/testing.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -24,4 +24,3 @@
AppCatalogLayer = ZCMLLayer(
os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
__name__, 'AppCatalogLayer', allow_teardown=True)
-
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/tests.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/tests.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/tests.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1,618 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Tests for catalog
-
-Note that indexes &c already have test suites, we only have to check that
-a catalog passes on events that it receives.
-
-$Id$
-"""
-import unittest
-from zope.testing import doctest
-from zope.interface import implements
-from zope.interface.verify import verifyObject
-from zope.app.testing import ztapi, setup, placelesssetup
-from BTrees.IFBTree import IFSet
-from zope.app.intid.interfaces import IIntIds
-from zope.app.component.hooks import setSite
-from zope.location.location import Location
-
-from zope.index.interfaces import IInjection, IIndexSearch
-from zope.app.catalog.interfaces import ICatalog
-from zope.app.catalog.catalog import Catalog
-from zope.app.catalog.field import FieldIndex
-
-class ReferenceStub:
- def __init__(self, obj):
- self.obj = obj
-
- def __call__(self):
- return self.obj
-
-
-class IntIdsStub:
- """A stub for IntIds."""
- implements(IIntIds)
-
- def __init__(self):
- self.ids = {}
- self.objs = {}
- self.lastid = 0
-
- def _generateId(self):
- self.lastid += 1
- return self.lastid
-
- def register(self, ob):
- if ob not in self.ids:
- uid = self._generateId()
- self.ids[ob] = uid
- self.objs[uid] = ob
- return uid
- else:
- return self.ids[ob]
-
- def unregister(self, ob):
- uid = self.ids[ob]
- del self.ids[ob]
- del self.objs[id]
-
- def getObject(self, uid):
- return self.objs[uid]
-
- def getId(self, ob):
- return self.ids[ob]
-
- def queryId(self, ob, default=None):
- return self.ids.get(ob, default)
-
- def __iter__(self):
- return self.objs.iterkeys()
-
-
-class StubIndex:
- """A stub for Index."""
-
- implements(IIndexSearch, IInjection)
-
- def __init__(self, field_name, interface=None):
- self._field_name = field_name
- self.interface = interface
- self.doc = {}
-
- def index_doc(self, docid, obj):
- self.doc[docid] = obj
-
- def unindex_doc(self, docid):
- del self.doc[docid]
-
- def apply(self, term):
- results = []
- for docid in self.doc:
- obj = self.doc[docid]
- fieldname = getattr(obj, self._field_name, '')
- if fieldname == term:
- results.append(docid)
- return IFSet(results)
-
-
-class stoopid:
- def __init__(self, **kw):
- self.__dict__ = kw
-
-
-class Test(placelesssetup.PlacelessSetup, unittest.TestCase):
-
- def test_catalog_add_del_indexes(self):
- catalog = Catalog()
- verifyObject(ICatalog, catalog)
- index = StubIndex('author', None)
- catalog['author'] = index
- self.assertEqual(list(catalog.keys()), ['author'])
- index = StubIndex('title', None)
- catalog['title'] = index
- indexes = list(catalog.keys())
- indexes.sort()
- self.assertEqual(indexes, ['author', 'title'])
- del catalog['author']
- self.assertEqual(list(catalog.keys()), ['title'])
-
- def _frob_intidutil(self, ints=True, apes=True):
- uidutil = IntIdsStub()
- ztapi.provideUtility(IIntIds, uidutil)
- # whack some objects in our little objecthub
- if ints:
- for i in range(10):
- uidutil.register("<object %s>"%i)
- if apes:
- uidutil.register(stoopid(simiantype='monkey', name='bobo'))
- uidutil.register(stoopid(simiantype='monkey', name='bubbles'))
- uidutil.register(stoopid(simiantype='monkey', name='ginger'))
- uidutil.register(stoopid(simiantype='bonobo', name='ziczac'))
- uidutil.register(stoopid(simiantype='bonobo', name='bobo'))
- uidutil.register(stoopid(simiantype='punyhuman', name='anthony'))
- uidutil.register(stoopid(simiantype='punyhuman', name='andy'))
- uidutil.register(stoopid(simiantype='punyhuman', name='kev'))
-
- def test_updateindexes(self):
- """Test a full refresh."""
- self._frob_intidutil()
- catalog = Catalog()
- catalog['author'] = StubIndex('author', None)
- catalog['title'] = StubIndex('author', None)
- catalog.updateIndexes()
- for index in catalog.values():
- checkNotifies = index.doc
- self.assertEqual(len(checkNotifies), 18)
-
- def test_updateindex(self):
- """Test a full refresh."""
- self._frob_intidutil()
- catalog = Catalog()
- catalog['author'] = StubIndex('author', None)
- catalog['title'] = StubIndex('author', None)
- catalog.updateIndex(catalog['author'])
- checkNotifies = catalog['author'].doc
- self.assertEqual(len(checkNotifies), 18)
- checkNotifies = catalog['title'].doc
- self.assertEqual(len(checkNotifies), 0)
-
- def test_basicsearch(self):
- """Test the simple search results interface."""
- self._frob_intidutil(ints=0)
- catalog = Catalog()
- catalog['simiantype'] = StubIndex('simiantype', None)
- catalog['name'] = StubIndex('name', None)
- catalog.updateIndexes()
-
- res = catalog.searchResults(simiantype='monkey')
- names = [x.name for x in res]
- names.sort()
- self.assertEqual(len(names), 3)
- self.assertEqual(names, ['bobo', 'bubbles', 'ginger'])
-
- res = catalog.searchResults(name='bobo')
- names = [x.simiantype for x in res]
- names.sort()
- self.assertEqual(len(names), 2)
- self.assertEqual(names, ['bonobo', 'monkey'])
-
- res = catalog.searchResults(simiantype='punyhuman', name='anthony')
- self.assertEqual(len(res), 1)
- ob = iter(res).next()
- self.assertEqual((ob.name, ob.simiantype), ('anthony', 'punyhuman'))
-
- res = catalog.searchResults(simiantype='ape', name='bobo')
- self.assertEqual(len(res), 0)
-
- res = catalog.searchResults(simiantype='ape', name='mwumi')
- self.assertEqual(len(res), 0)
- self.assertRaises(KeyError, catalog.searchResults,
- simiantype='monkey', hat='beret')
-
-
-class CatalogStub:
- implements(ICatalog)
- def __init__(self):
- self.regs = []
- self.unregs = []
-
- def index_doc(self, docid, doc):
- self.regs.append((docid, doc))
-
- def unindex_doc(self, docid):
- self.unregs.append(docid)
-
-class Stub(Location):
- pass
-
-
-class TestEventSubscribers(unittest.TestCase):
-
- def setUp(self):
- self.root = setup.placefulSetUp(True)
- sm = self.root.getSiteManager()
- self.utility = setup.addUtility(sm, '', IIntIds, IntIdsStub())
- self.cat = setup.addUtility(sm, '', ICatalog, CatalogStub())
- setSite(self.root)
-
- def tearDown(self):
- setup.placefulTearDown()
-
- def test_indexDocSubscriber(self):
- from zope.app.catalog.catalog import indexDocSubscriber
- from zope.container.contained import ObjectAddedEvent
- from zope.app.intid.interfaces import IntIdAddedEvent
-
- ob = Stub()
- ob2 = Stub()
-
- self.root['ob'] = ob
- self.root['ob2'] = ob2
-
- id = self.utility.register(ob)
- indexDocSubscriber(IntIdAddedEvent(ob, ObjectAddedEvent(ob2)))
-
- self.assertEqual(self.cat.regs, [(id, ob)])
- self.assertEqual(self.cat.unregs, [])
-
- def test_reindexDocSubscriber(self):
- from zope.app.catalog.catalog import reindexDocSubscriber
- from zope.lifecycleevent import ObjectModifiedEvent
-
- ob = Stub()
- self.root['ob'] = ob
-
- id = self.utility.register(ob)
-
- reindexDocSubscriber(ObjectModifiedEvent(ob))
-
- self.assertEqual(self.cat.regs, [(1, ob)])
- self.assertEqual(self.cat.unregs, [])
-
- ob2 = Stub()
- self.root['ob2'] = ob2
-
- reindexDocSubscriber(ObjectModifiedEvent(ob2))
- self.assertEqual(self.cat.regs, [(1, ob)])
- self.assertEqual(self.cat.unregs, [])
-
-
- def test_unindexDocSubscriber(self):
- from zope.app.catalog.catalog import unindexDocSubscriber
- from zope.container.contained import ObjectRemovedEvent
- from zope.app.intid.interfaces import IntIdRemovedEvent
-
- ob = Stub()
- ob2 = Stub()
- ob3 = Stub()
- self.root['ob'] = ob
- self.root['ob2'] = ob2
- self.root['ob3'] = ob3
-
- id = self.utility.register(ob)
-
- unindexDocSubscriber(
- IntIdRemovedEvent(ob2, ObjectRemovedEvent(ob3)))
- self.assertEqual(self.cat.unregs, [])
- self.assertEqual(self.cat.regs, [])
-
- unindexDocSubscriber(
- IntIdRemovedEvent(ob, ObjectRemovedEvent(ob3)))
- self.assertEqual(self.cat.unregs, [id])
- self.assertEqual(self.cat.regs, [])
-
-
-class TestIndexUpdating(unittest.TestCase) :
- """Issue #466: When reindexing a catalog it takes all objects from
- the nearest IntId utility. This is a problem when IntId utility
- lives in another site than the one.
-
- To solve this issue we simply check whether the objects are living
- within the nearest site.
- """
-
- def setUp(self):
-
- setup.placefulSetUp(True)
-
- from zope.app.catalog.catalog import Catalog
-
- self.root = setup.buildSampleFolderTree()
-
- subfolder = self.root[u'folder1'][u'folder1_1']
- root_sm = self.root_sm = setup.createSiteManager(self.root)
- local_sm = self.local_sm = setup.createSiteManager(subfolder)
- self.utility = setup.addUtility(root_sm, '', IIntIds, IntIdsStub())
- self.cat = setup.addUtility(local_sm, '', ICatalog, Catalog())
- self.cat['name'] = StubIndex('__name__', None)
-
- for obj in self.iterAll(self.root) :
- self.utility.register(obj)
-
- def tearDown(self):
- setup.placefulTearDown()
-
- def iterAll(self, container) :
- from zope.container.interfaces import IContainer
- for value in container.values() :
- yield value
- if IContainer.providedBy(value) :
- for obj in self.iterAll(value) :
- yield obj
-
- def test_visitSublocations(self) :
- """ Test the iterContained method which should return only the
- sublocations which are registered by the IntIds.
- """
-
- names = sorted([ob.__name__ for i, ob in self.cat._visitSublocations()])
- self.assertEqual(names, [u'folder1_1', u'folder1_1_1', u'folder1_1_2'])
-
- def test_updateIndex(self):
- """ Setup a catalog deeper within the containment hierarchy
- and call the updateIndexes method. The indexed objects should should
- be restricted to the sublocations.
- """
- self.cat.updateIndexes()
- index = self.cat['name']
- names = sorted([ob.__name__ for i, ob in index.doc.items()])
- self.assertEqual(names, [u'folder1_1', u'folder1_1_1', u'folder1_1_2'])
-
- def test_optimizedUpdateIndex(self):
- """ Setup a catalog deeper within the containment hierarchy together
- with its intid utility. The catalog will not visit sublocations
- because the intid utility can not contain objects outside the site
- where it is registered.
- """
- utility = setup.addUtility(self.local_sm, '', IIntIds, IntIdsStub())
- subfolder = self.root[u'folder1'][u'folder1_1']
- for obj in self.iterAll(subfolder) :
- utility.register(obj)
-
- self.cat.updateIndexes()
- index = self.cat['name']
- names = sorted([ob.__name__ for i, ob in index.doc.items()])
- self.assertEqual(names, [u'folder1_1_1', u'folder1_1_2'])
-
-
-class TestSubSiteCatalog(unittest.TestCase) :
- """If a catalog is defined in a sub site and the hooks.setSite was
- not set the catalog will not be found unless the context in
- getAllUtilitiesRegisteredFor is set.
- """
-
- def setUp(self):
-
- setup.placefulSetUp(True)
-
- from zope.app.catalog.catalog import Catalog
-
- self.root = setup.buildSampleFolderTree()
-
- self.subfolder = self.root[u'folder1'][u'folder1_1']
- root_sm = self.root_sm = setup.createSiteManager(self.root)
- local_sm = self.local_sm = setup.createSiteManager(self.subfolder)
- self.utility = setup.addUtility(root_sm, '', IIntIds, IntIdsStub())
- self.cat = setup.addUtility(local_sm, '', ICatalog, Catalog())
- self.cat['name'] = StubIndex('__name__', None)
-
- for obj in self.iterAll(self.root) :
- self.utility.register(obj)
-
-
- def tearDown(self):
- setup.placefulTearDown()
-
- def iterAll(self, container) :
- from zope.container.interfaces import IContainer
- for value in container.values() :
- yield value
- if IContainer.providedBy(value) :
- for obj in self.iterAll(value) :
- yield obj
-
-
-
- def test_Index(self):
- """ Setup a catalog deeper within the containment hierarchy
- and call the updateIndexes method. The indexed objects should should
- be restricted to the sublocations.
- """
- from zope.app.catalog.catalog import indexDocSubscriber
- from zope.container.contained import ObjectAddedEvent
-
- ob = Stub()
- self.subfolder['ob'] = ob
-
- id = self.utility.register(ob)
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 0)
-
- setSite(None)
- indexDocSubscriber(ObjectAddedEvent(ob))
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 1)
-
-
- def test_updateIndex(self):
- """ Setup a catalog deeper within the containment hierarchy
- and call the updateIndexes method. The indexed objects should should
- be restricted to the sublocations.
- """
- from zope.app.catalog.catalog import reindexDocSubscriber
- from zope.lifecycleevent import ObjectModifiedEvent
-
- ob = Stub()
- self.subfolder['ob'] = ob
-
- id = self.utility.register(ob)
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 0)
-
- setSite(None)
- reindexDocSubscriber(ObjectModifiedEvent(ob))
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 1)
-
- def test_UnIndex(self):
- """ Setup a catalog deeper within the containment hierarchy
- and call the updateIndexes method. The indexed objects should should
- be restricted to the sublocations.
- """
- from zope.app.catalog.catalog import indexDocSubscriber
- from zope.container.contained import ObjectAddedEvent
- from zope.app.catalog.catalog import unindexDocSubscriber
- from zope.container.contained import ObjectRemovedEvent
-
- ob = Stub()
- self.subfolder['ob'] = ob
-
- id = self.utility.register(ob)
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 0)
-
- setSite(None)
- indexDocSubscriber(ObjectAddedEvent(ob))
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 1)
-
- setSite(None)
- unindexDocSubscriber(ObjectRemovedEvent(ob))
-
- setSite(self.subfolder)
- res = self.cat.searchResults(name='ob')
- self.assertEqual(len(res), 0)
-
-
-class TestCatalogBugs(placelesssetup.PlacelessSetup, unittest.TestCase):
- """I found that z.a.catalog, AttributeIndex failed to remove the previous
- value/object from the index IF the NEW value is None.
- """
-
- def test_updateIndexWithNone(self):
- uidutil = IntIdsStub()
- ztapi.provideUtility(IIntIds, uidutil)
-
- catalog = Catalog()
- index = FieldIndex('author', None)
- catalog['author'] = index
-
- ob1 = stoopid(author = "joe")
- ob1id = uidutil.register(ob1)
- catalog.index_doc(ob1id, ob1)
-
- res = catalog.searchResults(author=('joe','joe'))
- names = [x.author for x in res]
- names.sort()
- self.assertEqual(len(names), 1)
- self.assertEqual(names, ['joe'])
-
- ob1.author = None
- catalog.index_doc(ob1id, ob1)
-
- #the index must be empty now because None values are never indexed
- res = catalog.searchResults(author=(None, None))
- self.assertEqual(len(res), 0)
-
- def test_updateIndexFromCallableWithNone(self):
- uidutil = IntIdsStub()
- ztapi.provideUtility(IIntIds, uidutil)
-
- catalog = Catalog()
- index = FieldIndex('getAuthor', None, field_callable=True)
- catalog['author'] = index
-
- ob1 = stoopidCallable(author = "joe")
-
- ob1id = uidutil.register(ob1)
- catalog.index_doc(ob1id, ob1)
-
- res = catalog.searchResults(author=('joe','joe'))
- names = [x.author for x in res]
- names.sort()
- self.assertEqual(len(names), 1)
- self.assertEqual(names, ['joe'])
-
- ob1.author = None
- catalog.index_doc(ob1id, ob1)
-
- #the index must be empty now because None values are never indexed
- res = catalog.searchResults(author=(None, None))
- self.assertEqual(len(res), 0)
-
-class stoopidCallable(object):
- def __init__(self, **kw):
- #leave the door open to not to set self.author
- self.__dict__.update(kw)
-
- def getAuthor(self):
- return self.author
-
-class TestIndexRaisingValueGetter(placelesssetup.PlacelessSetup, unittest.TestCase):
- """ """
- def test_IndexRaisingValueGetter(self):
- """We can have indexes whose values are determined by callable
- methods.
- Raising an exception in the method should not be silently ignored
- That would cause index corruption -- the index would be out of sync"""
- uidutil = IntIdsStub()
- ztapi.provideUtility(IIntIds, uidutil)
-
- catalog = Catalog()
- index = FieldIndex('getAuthor', None, field_callable=True)
- catalog['author'] = index
-
- ob1 = stoopidCallable(author = "joe")
- ob1id = uidutil.register(ob1)
- catalog.index_doc(ob1id, ob1)
-
- res = catalog.searchResults(author=('joe','joe'))
- names = [x.author for x in res]
- names.sort()
- self.assertEqual(len(names), 1)
- self.assertEqual(names, ['joe'])
-
- ob2 = stoopidCallable() # no author here, will raise AttributeError
- ob2id = uidutil.register(ob2)
- try:
- catalog.index_doc(ob2id, ob2)
- self.fail("AttributeError exception should be raised")
- except AttributeError:
- #this is OK, we WANT to have the exception
- pass
-
-
-def setUp(test):
- root = setup.placefulSetUp(True)
- test.globs['root'] = root
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- suite.addTest(unittest.makeSuite(TestEventSubscribers))
- suite.addTest(unittest.makeSuite(TestIndexUpdating))
- suite.addTest(unittest.makeSuite(TestSubSiteCatalog))
- suite.addTest(unittest.makeSuite(TestCatalogBugs))
- suite.addTest(unittest.makeSuite(TestIndexRaisingValueGetter))
- suite.addTest(doctest.DocTestSuite('zope.app.catalog.attribute'))
- suite.addTest(doctest.DocFileSuite(
- 'README.txt',
- setUp=placelesssetup.setUp,
- tearDown=placelesssetup.tearDown,
- ))
- suite.addTest(doctest.DocFileSuite(
- 'event.txt',
- setUp=setUp,
- tearDown=lambda x: setup.placefulTearDown(),
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ))
-
- return suite
-
-
-if __name__ == "__main__":
- unittest.main()
Modified: zope.app.catalog/trunk/src/zope/app/catalog/text.py
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/text.py 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/text.py 2009-02-01 16:20:36 UTC (rev 95862)
@@ -15,43 +15,5 @@
$Id$
"""
-import zope.index.text
-import zope.index.text.interfaces
-import zope.interface
-import zope.app.catalog.attribute
-import zope.app.catalog.interfaces
-import zope.container.contained
-from zope.i18nmessageid import ZopeMessageFactory as _
-
-class ITextIndex(zope.app.catalog.interfaces.IAttributeIndex,
- zope.app.catalog.interfaces.ICatalogIndex):
- """Interface-based catalog text index
- """
-
- interface = zope.schema.Choice(
- title=_(u"Interface"),
- description=_(u"Objects will be adapted to this interface"),
- vocabulary=_("Interfaces"),
- required=False,
- default=zope.index.text.interfaces.ISearchableText,
- )
-
- field_name = zope.schema.BytesLine(
- title=_(u"Field Name"),
- description=_(u"Name of the field to index"),
- default="getSearchableText"
- )
-
- field_callable = zope.schema.Bool(
- title=_(u"Field Callable"),
- description=_(u"If true, then the field should be called to get the "
- u"value to be indexed"),
- default=True,
- )
-
-class TextIndex(zope.app.catalog.attribute.AttributeIndex,
- zope.index.text.TextIndex,
- zope.container.contained.Contained):
-
- zope.interface.implements(ITextIndex)
+from zope.catalog.text import ITextIndex, TextIndex # BBB
Deleted: zope.app.catalog/trunk/src/zope/app/catalog/zope.app.catalog-configure.zcml
===================================================================
--- zope.app.catalog/trunk/src/zope/app/catalog/zope.app.catalog-configure.zcml 2009-02-01 16:12:22 UTC (rev 95861)
+++ zope.app.catalog/trunk/src/zope/app/catalog/zope.app.catalog-configure.zcml 2009-02-01 16:20:36 UTC (rev 95862)
@@ -1 +0,0 @@
-<include package="zope.app.catalog"/>
More information about the Checkins
mailing list