source: main/waeup.kofa/trunk/src/waeup/kofa/catalog.py @ 9721

Last change on this file since 9721 was 9217, checked in by uli, 12 years ago

Merge changes from uli-async-update back into trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1## $Id: catalog.py 9217 2012-09-21 11:21:05Z uli $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""Components to help cataloging and searching objects.
19"""
20import grok
21from hurry.query.interfaces import IQuery
22from hurry.query.query import Query
23from zope.catalog.catalog import ResultSet
24from zope.component import getUtility
25from zope.intid.interfaces import IIntIds
26from waeup.kofa.interfaces import IQueryResultItem
27
28# not yet used
29class KofaQuery(Query):
30    """A hurry.query-like query that supports also ``apply``.
31    """
32    grok.implements(IQuery)
33
34    def apply(self, query):
35        """Get a catalog's BTree set of intids conforming to a query.
36        """
37        return query.apply()
38
39    def searchResults(self, query):
40        """Get a set of ZODB objects conforming to a query.
41        """
42        results = self.apply(query)
43        if results is not None:
44            uidutil = getUtility(IIntIds)
45            results = ResultSet(results, uidutil)
46        return results
47
48grok.global_utility(KofaQuery)
49
50# not yet used
51class QueryResultItem(object):
52    grok.implements(IQueryResultItem)
53    url = None
54    title = None
55    description = None
56
57    def __init__(self, context, view):
58        self.context = context
59        self.url = view.url(context)
60        self.title = context.title
61        self.description = ''
Note: See TracBrowser for help on using the repository browser.