Skip to content

Commit

Permalink
Tests DO pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
trollfot committed Apr 29, 2012
1 parent f44a273 commit 7c55288
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def read(*rnames):
'zope.configuration',
'zope.location',
'zope.testing',
'zope.app.wsgi',
]

setup(
Expand Down Expand Up @@ -57,6 +58,7 @@ def read(*rnames):
'zope.interface',
'zope.intid',
'zope.lifecycleevent',
'zope.keyreference',
'zope.site',
],
tests_require=tests_require,
Expand Down
10 changes: 7 additions & 3 deletions src/grokcore/catalog/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok">


<include package="zope.catalog" />
<include package="zope.intid" />
<include package="zope.keyreference" />

<include package="zope.catalog" file="subscribers.zcml" />

<include package="grokcore.site" />
<include package="grokcore.site" file="meta.zcml" />
<include package="zope.intid" file="subscribers.zcml" />

<include package="." file="meta.zcml" />
<include package="zope.container" />
<include package="grokcore.site" />

</configure>
2 changes: 2 additions & 0 deletions src/grokcore/catalog/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
i18n_domain="grokcore.catalog"
package="grokcore.catalog">


<include package="zope.container" />
<include package="zope.app.appsetup" file="ftesting.zcml" />
<include package="grokcore.catalog" />
<grok:grok package="grokcore.catalog.ftests" />
Expand Down
4 changes: 2 additions & 2 deletions src/grokcore/catalog/ftests/test_grok_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from pkg_resources import resource_listdir
from zope.testing import doctest
from zope.app.appsetup.testlayer import ZODBLayer
from zope.app.wsgi.testlayer import BrowserLayer


FunctionalLayer = ZODBLayer(grokcore.catalog)
FunctionalLayer = BrowserLayer(grokcore.catalog)


def suiteFromPackage(name):
Expand Down
35 changes: 21 additions & 14 deletions src/grokcore/catalog/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@


class IndexDefinition(object):
"""The definition of a particular index in a :data:`grok.Indexes`
class.
"""The definition of a particular index in a
:data:`grokcore.catalog.Indexes` class.
This base class defines the actual behavior of
:class:`grokcore.catalog.index.Field` and the other kinds of attribute
index that Grok supports. Upon our instantiation, we save every
parameter that we were passed; later, if an index actually needs
to be created (which is typically at the moment when a new
:class:`grok.Application` object is added to the Zope Database),
:class:`grokcore.site.Application` object is added to the Zope Database),
then our :meth:`setup()` method gets called.
The only parameter that is actually significant to us is `attribute`
Expand Down Expand Up @@ -69,7 +69,8 @@ def __init__(self, *args, **kw):
def setup(self, catalog, name, context, module_info):
# If the user supplied attribute= when instantiating us, we
# allow that value to override the attribute name under which we
# are actually stored inside of the `grok.Indexes` instance.
# are actually stored inside of the `grokcore.catalog.Indexes`
# instance.
if self._attribute is not None:
field_name = self._attribute
else:
Expand All @@ -79,10 +80,11 @@ def setup(self, catalog, name, context, module_info):
try:
method = context[field_name]
except KeyError:
raise GrokError("grok.Indexes in %r refers to an attribute or "
"method %r on interface %r, but this does not "
"exist." % (module_info.getModule(),
field_name, context), None)
raise GrokError(
"grokcore.catalog.Indexes in %r refers to an attribute or "
"method %r on interface %r, but this does not "
"exist." % (module_info.getModule(),
field_name, context), None)
call = IMethod.providedBy(method)
else:
call = callable(getattr(context, field_name, None))
Expand All @@ -94,24 +96,29 @@ def setup(self, catalog, name, context, module_info):


class Field(IndexDefinition):
"""A :class:`grok.Indexes` index that matches against an entire field."""
"""A :class:`grokcore.catalog.Indexes` index that matches
against an entire field.
"""
index_class = FieldIndex


class Text(IndexDefinition):
"""A :class:`grok.Indexes` index supporting full-text searches of a
field."""
"""A :class:`grokcore.catalog.Indexes` index supporting
full-text searches of a field.
"""
index_class = TextIndex


class Set(IndexDefinition):
"""A :class:`grok.Indexes` index supporting keyword searches of a field."""
"""A :class:`grokcore.catalog.Indexes` index supporting
keyword searches of a field.
"""
index_class = SetIndex


class Value(IndexDefinition):
"""A :class:`grok.Indexes` index similar to, but more flexible than
:class:`grok.Field` index.
"""A :class:`grokcore.catalog.Indexes` index similar to,
but more flexible than :class:`grokcore.catalog.Field` index.
The index allows searches for documents that contain any of a set of
values; between a set of values; any (non-None) values; and any empty
Expand Down
4 changes: 2 additions & 2 deletions src/grokcore/catalog/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def grok(self, name, factory, module_info, config, **kw):

if site is None:
raise GrokError(
"No site specified for grok.Indexes "
"No site specified for grokcore.catalog.Indexes "
"subclass in module %r. "
"Use grokcore.site.site() to specify."
% module_info.getModule(), factory)
Expand Down Expand Up @@ -98,7 +98,7 @@ def __call__(self, site, event):
index.setup(catalog, name, self.context, self.module_info)
except DuplicationError:
raise GrokError(
"grok.Indexes in module %r causes "
"grokcore.catalog.Indexes in module %r causes "
"creation of catalog index %r in catalog %r, "
"but an index with that name is already present." %
(self.module_info.getModule(), name, self.catalog_name),
Expand Down
2 changes: 1 addition & 1 deletion src/grokcore/catalog/tests/catalog/indexes_no_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
>>> testing.grok(__name__)
Traceback (most recent call last):
...
GrokError: No site specified for grok.Indexes subclass in module
GrokError: No site specified for grokcore.catalog.Indexes subclass in module
<module 'grokcore.catalog.tests.catalog.indexes_no_app' from ...>.
Use grokcore.site.site() to specify.
Expand Down

0 comments on commit 7c55288

Please sign in to comment.