diff --git a/README.txt b/README.txt index 0f1c80b..fe66109 100755 --- a/README.txt +++ b/README.txt @@ -186,8 +186,9 @@ predicates: Searchable Text Adapter ----------------------- - >>> from loops.concept import SearchableText - >>> SearchableText(cc2).searchableText() + >>> from loops.concept import IndexAttributes + >>> idx = IndexAttributes(cc2) + >>> idx.text() u'cc2 Zope 3' Resources and what they have to do with Concepts diff --git a/browser/concept.py b/browser/concept.py index 2c8da33..8753751 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -122,7 +122,7 @@ class ConceptView(BaseView): searchTerm = request.get('searchTerm', None) if searchTerm: cat = zapi.getUtility(ICatalog) - result = cat.searchResults(loops_searchableText=searchTerm) + result = cat.searchResults(loops_text=searchTerm) else: result = self.loopsRoot.getConceptManager().values() searchType = request.get('searchType', '*') diff --git a/browser/node.py b/browser/node.py index 7733965..5aea80f 100644 --- a/browser/node.py +++ b/browser/node.py @@ -211,7 +211,7 @@ class ConfigureView(BaseView): searchTerm = request.get('searchTerm', None) if searchTerm: cat = zapi.getUtility(ICatalog) - result = cat.searchResults(loops_searchableText=searchTerm) + result = cat.searchResults(loops_text=searchTerm) else: result = (list(self.loopsRoot.getConceptManager().values()) + list(self.loopsRoot.getResourceManager().values())) diff --git a/concept.py b/concept.py index 135f195..9204393 100644 --- a/concept.py +++ b/concept.py @@ -40,7 +40,7 @@ from cybertools.relation.interfaces import IRelationRegistry, IRelatable from interfaces import IConcept, IConceptRelation, IConceptView from interfaces import IConceptManager, IConceptManagerContained from interfaces import ILoopsContained -from interfaces import ISearchableText +from interfaces import IIndexAttributes # relation classes @@ -296,15 +296,15 @@ class PredicateSourceList(object): return len(self.conceptTypes) -class SearchableText(object): +class IndexAttributes(object): - implements(ISearchableText) + implements(IIndexAttributes) adapts(IConcept) def __init__(self, context): self.context = context - def searchableText(self): + def text(self): context = self.context return ' '.join((zapi.getName(context), context.title,)) diff --git a/configure.zcml b/configure.zcml index fbc2e0d..128d3a2 100644 --- a/configure.zcml +++ b/configure.zcml @@ -232,7 +232,8 @@ - + + diff --git a/interfaces.py b/interfaces.py index 4f34728..9957570 100644 --- a/interfaces.py +++ b/interfaces.py @@ -455,12 +455,12 @@ class IConceptRelation(IRelation): # interfaces for catalog indexes -class ISearchableText(Interface): - """ Objects to be included in the general full-text index should provide - or be adaptable to this interface. +class IIndexAttributes(Interface): + """ Attributes odr methods providing index values. Typically provided + by an adapter. """ - def searchableText(): + def text(): """ Return a text with all parts to be indexed by a full-text index. """ diff --git a/resource.py b/resource.py index d490bf7..c879e25 100644 --- a/resource.py +++ b/resource.py @@ -26,6 +26,7 @@ from zope.app import zapi from zope.app.container.btree import BTreeContainer from zope.app.container.contained import Contained from zope.app.file.image import Image as BaseMediaAsset +from zope.component import adapts from zope.interface import implements from persistent import Persistent from cStringIO import StringIO @@ -37,6 +38,7 @@ from interfaces import IDocument, IDocumentSchema, IDocumentView from interfaces import IMediaAsset, IMediaAssetSchema, IMediaAssetView from interfaces import IResourceManager, IResourceManagerContained from interfaces import ILoopsContained +from interfaces import IIndexAttributes class Resource(Contained, Persistent): @@ -116,4 +118,16 @@ class ResourceManager(BTreeContainer): return self.getLoopsRoot().getViewManager() +class IndexAttributes(object): + + implements(IIndexAttributes) + adapts(IResource) + + def __init__(self, context): + self.context = context + + def text(self): + context = self.context + return ' '.join((zapi.getName(context), context.title,)) +