[Checkins] SVN: grok/trunk/doc/reference/components.rst Document the creation of the subscribers which automate the indexing. Clean-up example code a bit.
Kevin Teague
kevin at bud.ca
Wed Nov 25 20:37:00 EST 2009
Log message for revision 106019:
Document the creation of the subscribers which automate the indexing. Clean-up example code a bit.
Changed:
U grok/trunk/doc/reference/components.rst
-=-
Modified: grok/trunk/doc/reference/components.rst
===================================================================
--- grok/trunk/doc/reference/components.rst 2009-11-25 21:57:26 UTC (rev 106018)
+++ grok/trunk/doc/reference/components.rst 2009-11-26 01:37:00 UTC (rev 106019)
@@ -284,9 +284,13 @@
=====================
Indexes are containers for holding a set of indexes. An index is
-a data structures that provides a way of quickly finding a data objects.
+a data structures that provides a way of quickly finding data objects.
A single index can be of either `Field`, `Text`, or `Set`.
+When a `grok.Indexes` class is grokked, a subscriber is created which
+listens to `grok.IObjectAddedEvent' events specific to the `grok.context`
+of the declared for the class.
+
.. class:: grok.Indexes
Base class for catalog index definitions.
@@ -301,14 +305,14 @@
import grok
import grok.index
- from zope.interface import Interface
- from zope import schema
+ import zope.interface
+ import zope.schema
class Herd(grok.Container, grok.Application):
pass
- class IMammoth(Interface):
- name = schema.TextLine(title=u'Full Name')
+ class IMammoth(zope.interface.Interface):
+ name = zope.schema.TextLine(title=u'Full Name')
class MammothIndexes(grok.Indexes):
grok.site(Herd)
@@ -332,9 +336,11 @@
herd['two'] = Mammoth('Joe Mammoth')
herd['three'] = Mammoth('Marty the Wooly')
- from zope.app.catalog.interfaces import ICatalog
- from zope.component import getUtility
- catalog = getUtility(ICatalog)
+ import zope.catalog.interfaces
+ import zope.component
+ catalog = zope.component.getUtility(
+ zope.catalog.interfaces.ICatalog
+ )
mammoths = catalog.searchResults(full_name='Mammoth')
# mammoths would be a list containing 'Manfred Mammoth' and 'Joe Mammoth'
# but not 'Marty the Wooly'
More information about the checkins
mailing list