Commit d50be848 authored by Sidnei da Silva's avatar Sidnei da Silva

Updating interfaces at Shane's request, plus some whitespace cleaning

parent 148fd61b
......@@ -12,7 +12,7 @@
#
##############################################################################
"""
$Id: IZCatalog.py,v 1.5 2002/12/05 21:17:05 caseman Exp $
$Id: IZCatalog.py,v 1.6 2003/06/09 20:02:48 sidnei Exp $
"""
from Interface import Interface
......@@ -161,7 +161,7 @@ class IZCatalog(Interface):
sort_order -- You can specify 'reverse' or 'descending'.
Default behavior is to sort ascending.
sort_limit -- An optimization hint to tell the catalog how many
results you are really interested in. See the limit argument
to the search method for more details.
......@@ -196,30 +196,36 @@ class IZCatalog(Interface):
def __call__(REQUEST=None, **kw):
"""Search the catalog, the same way as 'searchResults'.
"""
def search(query_request, sort_index=None, reverse=0, limit=None, merge=1):
"""Programmatic search interface, use for searching the catalog from
scripts.
query_request -- Dictionary containing catalog query. This uses the
query_request -- Dictionary containing catalog query. This uses the
same format as searchResults.
sort_index -- Name of sort index
reverse -- Boolean, reverse sort order (defaults to false)
limit -- Limit sorted result count to the n best records. This is an
optimization hint used in conjunction with a sort_index. If possible
ZCatalog will use a different sort algorithm that uses much less memory
and scales better then a full sort. The actual number of records
returned is not guaranteed to be <= limit. You still need to apply the
same batching to the results. Since the len() of the results will no
same batching to the results. Since the len() of the results will no
longer be the actual result count, you can use the
"actual_result_count" attribute of the lazy result object instead to
determine the size of the full result set.
merge -- Return merged, lazy results (like searchResults) or raw
merge -- Return merged, lazy results (like searchResults) or raw
results for later merging. This can be used to perform multiple
queries (even across catalogs) and merge and sort the combined results.
"""
def refreshCatalog():
"""Reindex every object we can find, removing the unreachable
ones from the index.
"""
__doc__ = IZCatalog.__doc__ + __doc__
......@@ -135,13 +135,13 @@ class ZCatalog(Folder, Persistent, Implicit):
(search_zcatalog,
['searchResults', '__call__', 'uniqueValuesFor',
'getpath', 'schema', 'indexes', 'index_objects',
'getpath', 'schema', 'indexes', 'index_objects',
'all_meta_types', 'valid_roles', 'resolve_url',
'getobject', 'search'],
['Anonymous', 'Manager']),
(manage_zcatalog_indexes,
['getIndexObjects'],
(manage_zcatalog_indexes,
['getIndexObjects'],
['Manager']),
)
......@@ -614,24 +614,24 @@ class ZCatalog(Folder, Persistent, Implicit):
Search terms can be passed in the REQUEST or as keyword
arguments.
The used argument is now deprecated and ignored
"""
return self._catalog.searchResults(REQUEST, used, **kw)
__call__=searchResults
def search(
self, query_request, sort_index=None, reverse=0, limit=None, merge=1):
"""Programmatic search interface, use for searching the catalog from
scripts.
query_request: Dictionary containing catalog query
sort_index: Name of sort index
reverse: Reverse sort order?
limit: Limit sorted result count (optimization hint)
merge: Return merged results (like searchResults) or raw
merge: Return merged results (like searchResults) or raw
results for later merging.
"""
if sort_index is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment