Work in progress: indexing and searching

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1098 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-02-26 12:58:14 +00:00
parent a0948469d4
commit 57deb86205
7 changed files with 29 additions and 13 deletions

View file

@ -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

View file

@ -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', '*')

View file

@ -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()))

View file

@ -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,))

View file

@ -232,7 +232,8 @@
<!-- adapters -->
<adapter factory="loops.concept.SearchableText" />
<adapter factory="loops.concept.IndexAttributes" />
<adapter factory="loops.resource.IndexAttributes" />
<adapter factory="loops.external.NodesLoader" />
<adapter factory="loops.external.NodesExporter" />

View file

@ -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.
"""

View file

@ -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,))