[Checkins] SVN: grok/trunk/src/grok/ftests/catalog/ Removed most of the catalog tests. They live in grokcore.catalog

Souheil Chelfouh cvs-admin at zope.org
Mon Apr 30 08:51:48 UTC 2012


Log message for revision 125426:
  Removed most of the catalog tests. They live in grokcore.catalog
  Kept the form one
  

Changed:
  D   grok/trunk/src/grok/ftests/catalog/catalog.py
  D   grok/trunk/src/grok/ftests/catalog/indexes.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_app_interface.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_attribute.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_class.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_multiple.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_multiple_conflict.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_name.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_nonexistent.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_set.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_site.py
  D   grok/trunk/src/grok/ftests/catalog/indexes_valueindex.py
  D   grok/trunk/src/grok/ftests/catalog/setuporder.py

-=-
Deleted: grok/trunk/src/grok/ftests/catalog/catalog.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/catalog.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/catalog.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,59 +0,0 @@
-"""
-Let's setup a site in which we manage a couple of objects:
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site:
-
-  >>> herd['manfred'] = Mammoth('Manfred')
-  >>> herd['ellie'] = Mammoth('Ellie')
-
-Then we are able to query the catalog:
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> for obj in catalog.searchResults(name=('Ellie', 'Ellie')):
-  ...     print obj.name
-  Ellie
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> from zope import component
-  >>> sm = herd.getSiteManager()
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-"""
-
-import grok
-from zope import schema, interface
-from zope.intid import IntIds
-from zope.intid.interfaces import IIntIds
-from zope.catalog.catalog import Catalog
-from zope.catalog.interfaces import ICatalog
-from zope.catalog.field import FieldIndex
-
-def setup_catalog(catalog):
-    catalog['name'] = FieldIndex('name', IMammoth)
-
-class IMammoth(interface.Interface):
-
-    name = schema.TextLine()
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name):
-        self.name = name
-
-class Herd(grok.Container, grok.Site):
-    grok.local_utility(IntIds, provides=IIntIds)
-    grok.local_utility(Catalog, provides=ICatalog, setup=setup_catalog)

Deleted: grok/trunk/src/grok/ftests/catalog/indexes.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,101 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site::
-
-  >>> herd['alpha'] = Mammoth('Alpha', 13, 'Hello world!')
-  >>> herd['beta'] = Mammoth('Beta', 14, 'Bye World!')
-
-We are able to query the catalog::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> for obj in catalog.searchResults(name=('Beta', 'Beta')):
-  ...   print obj.name
-  Beta
-
-Let's query the text index, which incidentally also indexes a method::
-
-  >>> def sortedResults(catalog, **kw):
-  ...    result = list(catalog.searchResults(**kw))
-  ...    result.sort(key=lambda x:x.name)
-  ...    return [item.name for item in result]
-  >>> sortedResults(catalog, message='world')
-  ['Alpha', 'Beta']
-  >>> sortedResults(catalog, message='hello')
-  ['Alpha']
-  >>> sortedResults(catalog, message='bye')
-  ['Beta']
-
-Note that another application that we did not register the
-indexes for won't have a catalog available::
-
-  >>> herd2 = Herd2()
-  >>> getRootFolder()['herd2'] = herd2
-  >>> setSite(herd2)
-  >>> queryUtility(ICatalog, default=None) is None
-  True
-  >>> setSite(herd)
-  
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class Herd2(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-    def message():
-        """Message the mammoth has for the world."""
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name, age, message):
-        self.name = name
-        self.age = age
-        self._message = message
-
-    def message(self):
-        return self._message
-    

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_app_interface.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_app_interface.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_app_interface.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,102 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. Here we see how we can register indexes for
-an interface instead of an application directly.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-We are able to find the catalog::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> catalog is not None
-  True
-  >>> catalog.get('name') is not None
-  True
-
-Nuke the catalog and intids for this site, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Now let's create another application providing the same interface::
-
-  >>> herd2 = Herd2()
-  >>> getRootFolder()['herd2'] = herd2
-  >>> setSite(herd2)
-  >>> catalog = getUtility(ICatalog)
-  >>> catalog is not None
-  True
-  >>> catalog.get('name') is not None
-  True
-  
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd2.getSiteManager()
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-
-class IHerd(Interface):
-    pass
-
-
-class Herd(grok.Container, grok.Application):
-    grok.implements(IHerd)
-
-
-class Herd2(grok.Container, grok.Application):
-    grok.implements(IHerd)
-
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-    def message():
-        """Message the mammoth has for the world."""
-
-
-class MammothIndexes(grok.Indexes):
-    grok.site(IHerd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()
-
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name, age, message):
-        self.name = name
-        self.age = age
-        self._message = message
-
-    def message(self):
-        return self._message

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_attribute.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_attribute.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_attribute.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,67 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. If you want to name the index differently
-from the attribute, you can do so, by passing an explicit `attribute`
-keyword argument to the field.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site::
-
-  >>> herd['alpha'] = Mammoth('Alpha', 13)
-  >>> herd['beta'] = Mammoth('Beta', 14)
-
-We are able to query the catalog::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> for obj in catalog.searchResults(how_old=(13, 13)):
-  ...   print obj.name
-  Alpha
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-    how_old = index.Field(attribute='age')
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name, age):
-        self.name = name
-        self.age = age

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_class.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_class.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_class.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,77 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. This can also be done without explicit interface.
-The context of the indexes applies to a class in this case.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site::
-
-  >>> herd['alpha'] = Mammoth('Alpha', 13, 'Hello world!')
-  >>> herd['beta'] = Mammoth('Beta', 14, 'Bye World!')
-
-We are able to query the catalog::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> for obj in catalog.searchResults(name=('Beta', 'Beta')):
-  ...   print obj.name
-  Beta
-
-Let's query the text index, which incidentally also indexes a method::
-
-  >>> def sortedResults(catalog, **kw):
-  ...    result = list(catalog.searchResults(**kw))
-  ...    result.sort(key=lambda x:x.name)
-  ...    return [item.name for item in result]
-  >>> sortedResults(catalog, message='world')
-  ['Alpha', 'Beta']
-  >>> sortedResults(catalog, message='hello')
-  ['Alpha']
-  >>> sortedResults(catalog, message='bye')
-  ['Beta']
-  
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class Mammoth(grok.Model):
-    def __init__(self, name, age, message):
-        self.name = name
-        self.age = age
-        self._message = message
-
-    def message(self):
-        return self._message
-
-class MammothIndexes(grok.Indexes):
-    grok.context(Mammoth)
-    grok.site(Herd)
-    
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()
-

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_multiple.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_multiple.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_multiple.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,72 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. In fact, we have multiple grok.Indexes
-setting up more than one set of indexes in the same catalog.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-We are able to query the catalog::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> sorted(catalog.keys())
-  [u'age', u'age2', u'message', u'message2', u'name', u'name2']
-  
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-    def message():
-        """Message the mammoth has for the world."""
-
-class IMammoth2(Interface):
-    name2 = schema.TextLine(title=u'Name')
-    age2 = schema.Int(title=u'Age')
-    def message2():
-        """Message the mammoth has for the world."""
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()
-
-class MammothIndexes2(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth2)
-
-    name2 = index.Field()
-    age2 = index.Field()
-    message2 = index.Text()

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_multiple_conflict.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_multiple_conflict.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_multiple_conflict.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,62 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. In fact, we have multiple grok.Indexes
-setting up more than one set of indexes in the same catalog. What if these
-indexes define the same names?
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  Traceback (most recent call last):
-    ...
-  KeyError: u'name'
-
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-
-class IMammoth2(Interface):
-    name = schema.TextLine(title=u'Name')
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-
-class MammothIndexes2(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth2)
-
-    name = index.Field()

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_name.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_name.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_name.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,59 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. We can specify the catalog name using
-grok.name.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-
-We have to look up the catalog by name now::
-
-  >>> catalog = getUtility(ICatalog, 'foo_catalog')
-  >>> catalog
-  <zope.catalog.catalog.Catalog object at ...>
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog, name='foo_catalog')
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class Mammoth(grok.Model):
-    def __init__(self, name, age, message):
-        self.name = name
-        self.age = age
-        self._message = message
-
-    def message(self):
-        return self._message
-
-class MammothIndexes(grok.Indexes):
-    grok.context(Mammoth)
-    grok.name('foo_catalog')
-    grok.site(Herd)
-    
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_nonexistent.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_nonexistent.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_nonexistent.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,61 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. Here we show what happens if you try
-to set up an index for an attribute that does not exist on the interface.
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  Traceback (most recent call last):
-    ...
-  GrokError: grokcore.catalog.Indexes in <module
-  'grok.ftests.catalog.indexes_nonexistent' from ...>
-  refers to an attribute or method 'foo' on interface <InterfaceClass
-  grok.ftests.catalog.indexes_nonexistent.IMammoth>, but this does not
-  exist.
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-  >>> catalog = getUtility(ICatalog)
-
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-    def message():
-        """Message the mammoth has for the world."""
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    foo = index.Field()
-
-
-

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_set.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_set.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_set.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,72 +0,0 @@
-"""
-We now demonstrate the use of a SetIndex with Grok::
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site::
-
-  >>> herd['alpha'] = Mammoth('Alpha', ['big', 'brown'])
-  >>> herd['beta'] = Mammoth('Beta', ['big', 'black', 'friendly'])
-  >>> herd['gamma'] = Mammoth('Gamma', ['brown', 'friendly', 'gorgeous'])
-
-Let's query the set index::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> def sortedResults(catalog, **kw):
-  ...    result = list(catalog.searchResults(**kw))
-  ...    result.sort(key=lambda x:x.name)
-  ...    return [item.name for item in result]
-  >>> sortedResults(catalog, features={'any_of': ['brown']})
-  ['Alpha', 'Gamma']
-  >>> sortedResults(catalog, features={'any_of': ['big']})
-  ['Alpha', 'Beta']
-  >>> sortedResults(catalog, features={'any_of': ['friendly']})
-  ['Beta', 'Gamma']
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-
-from zope.interface import Interface, Attribute
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class IMammoth(Interface):
-    features = Attribute('Features')
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    features = index.Set()
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name, features):
-        self.name = name
-        self.features = features
-

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_site.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_site.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_site.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,56 +0,0 @@
-"""
-Grok allows you to set up catalog indexes in your application with a
-special indexes declaration. In fact, these indexes can be set up for
-any site::
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-The catalog is there in the site::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = queryUtility(ICatalog, default=None)
-  >>> catalog is not None
-  True
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-"""
-
-from zope.interface import Interface
-from zope import schema
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Site):
-    pass
-
-class IMammoth(Interface):
-    name = schema.TextLine(title=u'Name')
-    age = schema.Int(title=u'Age')
-    def message():
-        """Message the mammoth has for the world."""
-
-class MammothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(IMammoth)
-
-    name = index.Field()
-    age = index.Field()
-    message = index.Text()

Deleted: grok/trunk/src/grok/ftests/catalog/indexes_valueindex.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/indexes_valueindex.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/indexes_valueindex.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,73 +0,0 @@
-"""
-We now demonstrate the use of a ValueIndex with Grok::
-
-Let's set up a site in which we manage a couple of objects::
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site::
-
-  >>> herd['alpha'] = SabreTooth('Alpha', 'tolerant')
-  >>> herd['beta'] = SabreTooth('Beta', 'narrowminded')
-  >>> herd['gamma'] = SabreTooth('Gamma', 'friendly')
-
-Let's query the set index::
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility, queryUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> def sortedResults(catalog, **kw):
-  ...    result = list(catalog.searchResults(**kw))
-  ...    result.sort(key=lambda x:x.name)
-  ...    return [item.name for item in result]
-  >>> sortedResults(catalog, feature={'any_of': ['tolerant', 'friendly']})
-  ['Alpha', 'Gamma']
-
-  >>> sortedResults(catalog, feature={'any_of': ['narrowminded', 'foo']})
-  ['Beta']
-
-  >>> sortedResults(catalog, feature={'any_of': ['narrowminded', 'friendly']})
-  ['Beta', 'Gamma']
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> sm = herd.getSiteManager()
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> from zope.intid.interfaces import IIntIds
-  >>> from zope import component
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-Unfortunately ftests don't have good isolation from each other yet.
-"""
-
-from zope.interface import Interface, Attribute
-
-import grok
-from grok import index
-
-class Herd(grok.Container, grok.Application):
-    pass
-
-class ISabreTooth(Interface):
-    feature = Attribute('Feature')
-
-class SabreToothIndexes(grok.Indexes):
-    grok.site(Herd)
-    grok.context(ISabreTooth)
-
-    feature = index.Value()
-
-class SabreTooth(grok.Model):
-    grok.implements(ISabreTooth)
-
-    def __init__(self, name, features):
-        self.name = name
-        self.feature = features

Deleted: grok/trunk/src/grok/ftests/catalog/setuporder.py
===================================================================
--- grok/trunk/src/grok/ftests/catalog/setuporder.py	2012-04-30 08:49:43 UTC (rev 125425)
+++ grok/trunk/src/grok/ftests/catalog/setuporder.py	2012-04-30 08:51:44 UTC (rev 125426)
@@ -1,64 +0,0 @@
-"""
-This is similar to catalog.py, except that the site uses a base class
-which also defines a local utility.
-
-Let's setup a site in which we manage a couple of objects:
-
-  >>> herd = Herd()
-  >>> getRootFolder()['herd'] = herd
-  >>> from zope.site.hooks import setSite
-  >>> setSite(herd)
-
-Now we add some indexable objects to the site:
-
-  >>> herd['manfred'] = Mammoth('Manfred')
-  >>> herd['ellie'] = Mammoth('Ellie')
-
-Then we are able to query the catalog:
-
-  >>> from zope.catalog.interfaces import ICatalog
-  >>> from zope.component import getUtility
-  >>> catalog = getUtility(ICatalog)
-  >>> for obj in catalog.searchResults(name=('Ellie', 'Ellie')):
-  ...     print obj.name
-  Ellie
-
-Nuke the catalog and intids in the end, so as not to confuse
-other tests::
-
-  >>> from zope import component
-  >>> sm = herd.getSiteManager()
-  >>> sm.unregisterUtility(catalog, provided=ICatalog)
-  True
-  >>> intids = component.getUtility(IIntIds)
-  >>> sm.unregisterUtility(intids, provided=IIntIds)
-  True
-
-"""
-
-import grok
-from zope import schema, interface
-from zope.intid import IntIds
-from zope.intid.interfaces import IIntIds
-from zope.catalog.catalog import Catalog
-from zope.catalog.interfaces import ICatalog
-from zope.catalog.field import FieldIndex
-
-def setup_catalog(catalog):
-    catalog['name'] = FieldIndex('name', IMammoth)
-
-class IMammoth(interface.Interface):
-
-    name = schema.TextLine()
-
-class Mammoth(grok.Model):
-    grok.implements(IMammoth)
-
-    def __init__(self, name):
-        self.name = name
-
-class BaseHerd(grok.Container, grok.Site):
-    grok.local_utility(IntIds, provides=IIntIds)
-
-class Herd(BaseHerd):
-    grok.local_utility(Catalog, provides=ICatalog, setup=setup_catalog)



More information about the checkins mailing list