[Zope3-checkins] SVN: Zope3/branches/jim-index/src/zope/app/index/ Checking in work in progress to flush removed and moved files.

Jim Fulton jim at zope.com
Sat Jun 12 10:09:53 EDT 2004


Log message for revision 25394:
Checking in work in progress to flush removed and moved files.


-=-
Copied: Zope3/branches/jim-index/src/zope/app/index/field/browser (from rev 25384, Zope3/branches/jim-index/src/zope/app/index/browser/field)

Deleted: Zope3/branches/jim-index/src/zope/app/index/field/browser/control.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/index/browser/field/control.py	2004-06-12 10:51:53 UTC (rev 25384)
+++ Zope3/branches/jim-index/src/zope/app/index/field/browser/control.py	2004-06-12 14:09:52 UTC (rev 25394)
@@ -1,74 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Control view for the text index.
-
-$Id$
-"""
-from zope.app.introspector import interfaceToName
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.index.interfaces.text import IQueryView
-from zope.app.servicenames import HubIds
-from zope.app.traversing.api import canonicalPath
-from zope.component import getService, queryAdapter
-from zope.exceptions import NotFoundError
-from zope.interface import implements
-from zope.app.publisher.browser import BrowserView
-
-class ControlView(BrowserView):
-
-    implements(IQueryView)
-
-    def __init__(self, context, request):
-        super(ControlView, self).__init__(context, request)
-        self.hub = getService(HubIds)
-
-    def interface_name(self):
-        return interfaceToName(self.context, self.context.interface)
-
-    def query(self):
-        queryText = self.request.get('queryText', '')
-        results = self.context.search(queryText)
-        nresults = len(results)
-        first = 1
-        last = first + len(results) - 1
-        result = {
-            'results': list(self._resultIterator(results)),
-            'nresults': nresults,
-            'first': first,
-            'last': last,
-            'total': nresults,
-            }
-        return result
-
-    def _resultIterator(self, results):
-        for hubid in results:
-            yield self._cookInfo(hubid)
-
-    def _cookInfo(self, hubid):
-        location = canonicalPath(self.hub.getPath(hubid))
-        # XXX `location` is later used as a URL in a page template, using a
-        #     physical path instead of absolute_url will break virtual hosting.
-        result = {
-            'location': location,
-            }
-        try:
-            object = self.hub.getObject(hubid)
-        except NotFoundError:
-            pass
-        else:
-            dc = queryAdapter(object, IZopeDublinCore, context=self.context)
-            if dc is not None:
-                title = dc.title
-                result['title'] = title
-        return result

Copied: Zope3/branches/jim-index/src/zope/app/index/field/browser/control.py (from rev 25393, Zope3/branches/jim-index/src/zope/app/index/browser/field/control.py)

Copied: Zope3/branches/jim-index/src/zope/app/index/keyword/browser (from rev 25384, Zope3/branches/jim-index/src/zope/app/index/browser/keyword)

Copied: Zope3/branches/jim-index/src/zope/app/index/text/browser (from rev 25384, Zope3/branches/jim-index/src/zope/app/index/browser/text)

Deleted: Zope3/branches/jim-index/src/zope/app/index/text/browser/control.py
===================================================================
--- Zope3/branches/jim-index/src/zope/app/index/browser/text/control.py	2004-06-12 10:51:53 UTC (rev 25384)
+++ Zope3/branches/jim-index/src/zope/app/index/text/browser/control.py	2004-06-12 14:09:52 UTC (rev 25394)
@@ -1,98 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Control view for the text index.
-
-$Id$
-"""
-from zope.interface import implements
-from zope.component import getService, queryAdapter
-from zope.app.servicenames import HubIds
-from zope.exceptions import NotFoundError
-from zope.app.publisher.browser import BrowserView
-
-from zope.app.traversing.api import canonicalPath
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.index.interfaces.text import IQueryView
-
-class ControlView(BrowserView):
-    implements(IQueryView)
-
-    default_start = 0 # Don't change -- always start at first batch
-    default_count = 2 # Default batch size -- tune as you please
-
-    def __init__(self, context, request):
-        super(ControlView, self).__init__(context, request)
-        self.hub = getService(context, HubIds)
-
-    def nextBatch(self):
-        start = int(self.request.get('start', self.default_start))
-        count = int(self.request.get('count', self.default_count))
-        return start + count
-
-    def prevBatch(self):
-        start = int(self.request.get('start', self.default_start))
-        count = int(self.request.get('count', self.default_count))
-        return start - count
-
-    def query(self, start=None):
-        queryText = self.request.get('queryText', '')
-        if start is None:
-            start = int(self.request.get('start', self.default_start))
-        count = int(self.request.get('count', self.default_count))
-        results, total = self.context.query(queryText, start, count)
-        # XXX Two things:
-        #     1. query can raise an exception (QueryError or ParseError)
-        #     2. query is not in the IUITextIndex interface
-        nresults = len(results)
-        first = start + 1
-        last = first + len(results) - 1
-        result = {
-            'results': list(self._resultIterator(results)),
-            'nresults': nresults,
-            'first': first,
-            'last': last,
-            'total': total,
-            }
-        if start > 0:
-            prev = max(0, start - count)
-            result['prev'] = prev
-        if last < total:
-            next = start + count
-            result['next'] = next
-        return result
-
-    def _resultIterator(self, results):
-        for hubid, score in results:
-            yield self._cookInfo(hubid, score)
-
-    def _cookInfo(self, hubid, score):
-        location = canonicalPath(self.hub.getPath(hubid))
-        # XXX `location` is later used as a URL in a page template, using a
-        #     physical path instead of absolute_url will break virtual hosting.
-        scoreLabel = "%.1f%%" % (100.0 * score)
-        result = {
-            'location': location,
-            'score': score,
-            'scoreLabel': scoreLabel,
-            }
-        try:
-            object = self.hub.getObject(hubid)
-        except NotFoundError:
-            pass
-        else:
-            dc = queryAdapter(object, IZopeDublinCore, context=self.context)
-            if dc is not None:
-                title = dc.title
-                result['title'] = title
-        return result

Copied: Zope3/branches/jim-index/src/zope/app/index/text/browser/control.py (from rev 25393, Zope3/branches/jim-index/src/zope/app/index/browser/text/control.py)




More information about the Zope3-Checkins mailing list