[Zope3-checkins] CVS: Zope3/src/zope/app/index/interfaces -
__init__.py:1.1 field.py:1.1 interfaces.py:1.1 keyword.py:1.1
text.py:1.1
Philipp von Weitershausen
philikon at philikon.de
Tue Mar 2 09:40:12 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/index/interfaces
In directory cvs.zope.org:/tmp/cvs-serv24867/index/interfaces
Added Files:
__init__.py field.py interfaces.py keyword.py text.py
Log Message:
Moved index interfaces and browser views to zope.app.index.
=== Added File Zope3/src/zope/app/index/interfaces/__init__.py ===
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Index Interfaces
$Id: __init__.py,v 1.1 2004/03/02 14:40:10 philikon Exp $
"""
from zope.interface import Interface
class IInterfaceIndexer(Interface):
"""I index objects by first adapting them to an interface, then
retrieving a field on the adapted object.
"""
=== Added File Zope3/src/zope/app/index/interfaces/field.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Interfaces related to field indexing and searching.
$Id: field.py,v 1.1 2004/03/02 14:40:10 philikon Exp $
"""
from zope.interface import Interface
from zope.schema import BytesLine
from zope.app.component.interfacefield import InterfaceField
class IUIFieldCatalogIndex(Interface):
"""Interface for creating a FieldIndex in a catalog from the ZMI."""
interface = InterfaceField(
title=u"Interface",
description=u"Objects will be adapted to this interface",
required=False)
field_name = BytesLine(
title=u"Field Name",
description=u"Name of the field to index")
class IUIFieldIndex(IUIFieldCatalogIndex):
"""Interface for creating a FieldIndex from the ZMI (not in a catalog)."""
def subscribe():
"""Subscribe to the prevailing object hub service."""
def unsubscribe():
"""Unsubscribe from the object hub service."""
def isSubscribed():
"""Return whether we are currently subscribed."""
def documentCount():
"""Return number of indexed documents """
def search(values):
"""Return a set of hub IDs for all documents matching the values.
'values' can be a single value or a sequence of values. In the latter
case the IDs of documents matching any of the values will be returned.
"""
=== Added File Zope3/src/zope/app/index/interfaces/interfaces.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Standard interfaces for using the query service.
The query service provides a set of interfaces for articulating queries. You
can create complex queries by implementing multiple interfaces like
IBatchedQuery and ITextIndexQuery to ask the TextIndex for a batched query.
The lookup for the query processor will try to find an appropriate adapter to
the index.
$Id: interfaces.py,v 1.1 2004/03/02 14:40:10 philikon Exp $
"""
from zope.interface import Interface, Attribute
class IQueryDescription(Interface):
"""An interface the describes the input or output of a
query processor.
There should exist an adapter that adapts the type we
are describing to an object that implements this interface.
"""
class ITextIndexQuery(IQueryDescription):
"""A unicode query string that's compatible to the TextIndex
syntax.
"""
textIndexQuery = Attribute("The query.")
class IBatchedQuery(Interface):
startPosition = Attribute("The first element of the batch.")
batchSize = Attribute("The size of the batch.")
class IBatchedTextIndexQuery(IBatchedQuery, ITextIndexQuery):
pass
class IBatchedResult(IBatchedQuery):
totalSize = Attribute("The total size of the result set if known.")
class IHubIdSet(IQueryDescription):
"""Contains an IISet or IOSet of HubIds.
"""
iset = Attribute("The set of HubIds.")
class IRankedHubIdList(IQueryDescription):
"""Describes a sequence of tuples (hubid, rank) where
rank is a float between 0 and 1 inclusive.
"""
def __getitem__(index):
"""Returns a tuple (hubid, rank) with that index."""
class IInstrumentalQuery(Interface):
"""The original query in a form that was actually used.
"""
instrumentalQuery = Attribute("Contains the instrumental query.")
class IRankedObjectIterator(Interface):
"""Provides an iterable presentation of ranked results
of a ranked query. Each item is implementing an IRankedObjectRecord.
"""
def __iter__():
"""Iterates over the results."""
class IRankedObjectRecord(Interface):
"""One item returned by the iterator."""
rank = Attribute("A float between 0 and 1 inclusive.")
object = Attribute("The object.")
=== Added File Zope3/src/zope/app/index/interfaces/keyword.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Interfaces related to keyword indexing and searching.
Should be refactored (along with text and field)
$Id: keyword.py,v 1.1 2004/03/02 14:40:10 philikon Exp $
"""
from zope.interface import Interface
from zope.schema import BytesLine
from zope.app.component.interfacefield import InterfaceField
class IUIKeywordCatalogIndex(Interface):
"""Interface for creating a KeywordIndex in a catalog from the ZMI."""
interface = InterfaceField(
title=u"Interface",
description=u"Objects will be adapted to this interface",
required=False)
field_name = BytesLine(
title=u"Field Name",
description=u"Name of the field to index")
=== Added File Zope3/src/zope/app/index/interfaces/text.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Interfaces related to text indexing and searching.
$Id: text.py,v 1.1 2004/03/02 14:40:10 philikon Exp $
"""
from zope.interface import Interface
from zope.schema import BytesLine
from zope.app.component.interfacefield import InterfaceField
from zope.index.interfaces import IStatistics
class ISearchableText(Interface):
"""Interface that text-indexable objects should implement."""
def getSearchableText():
"""Return a sequence of unicode strings to be indexed.
Each unicode string in the returned sequence will be run
through the splitter pipeline; the combined stream of words
coming out of the pipeline will be indexed.
returning None indicates the object should not be indexed
"""
class IUITextCatalogIndex(IStatistics):
"""Interface for creating a TextIndex inside a catalog"""
interface = InterfaceField(
title=u"Interface",
description=u"Objects will be adapted to this interface",
required=False,
default=ISearchableText)
field_name = BytesLine(
title=u"Field Name",
description=u"Name of the field to index",
default="getSearchableText")
class IUITextIndex(IUITextCatalogIndex):
"""Interface for creating a TextIndex from the ZMI."""
def subscribe():
"""Subscribe to the prevailing object hub service."""
def unsubscribe():
"""Unsubscribe from the object hub service."""
def isSubscribed():
"""Return whether we are currently subscribed."""
class IQueryView(Interface):
"""Interface providing a query method that can be invoked from ZPT.
XXX How to express that this is a browser interface?"""
def query():
"""Perform a batched query, based on request fields.
These request fields are used as input:
start -- batch start (0-based); defaults to 0
count -- batch size; defaults to 10
queryText -- query expression; must be given
Return a dict with fields:
results -- a list containing the requested batch
nresults -- number of items in results
first -- 1-based ordinal this batch's first item
last -- 1-based ordinal of if this batch's last item
next -- 0-based ordinal of next batch; not set if no next batch
prev -- 0-based ordinal of previous batch; not set if no prev batch
count -- requested batch size
total -- total number of matches (all batches together)
Each item in the results set has the following string fields:
location -- location of the object (usable as URL within the site)
title -- Dublin Core title of the object; not present if no title
score -- score, as a float in the range [0.0 ... 1.0]
scoreLabel -- score, formatted as a percentage and rounded to 0.1%
"""
def nextBatch():
"""Return the start for the next batch."""
def prevBatch():
"""Return the start for the previous batch."""
More information about the Zope3-Checkins
mailing list