Ignore:
Timestamp:
4 Jan 2010, 22:49:01 (15 years ago)
Author:
uli
Message:

Remove viewing stuff that went to browser subpackage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/catalog.py

    r4485 r4662  
    7373     index = cat['code']
    7474     index.index_doc(intids.getId(obj), obj)
    75 
    76 
    77 from zope.interface import Interface
    78 from zope import schema
    79 
    80 class IQueryResultItem(Interface):
    81      url = schema.TextLine(
    82           title = u'URL that links to the found item')
    83      title = schema.TextLine(
    84           title = u'Title displayed in search results.')
    85      description = schema.Text(
    86           title = u'Longer description of the item found.')
    87      
    88      
    89 class QueryResultItem(object):
    90      grok.implements(IQueryResultItem)
    91      url = None
    92      title = None
    93      description = None
    94      
    95      def __init__(self, context, view):
    96           self.context = context
    97           self.url = view.url(context)
    98           self.title = context.title
    99           self.description = ''
    100      
    101 class CourseQueryResultItem(QueryResultItem):
    102      def __init__(self, context, view):
    103           self.context = context
    104           self.url = view.url(context)
    105           self.title = "COURSE: " + context.title
    106           self.description = 'code: %s' % context.code
    107 
    108 
    109 from waeup.viewlets import Search, MainArea
    110 from hurry.query.query import Query, Text, Eq
    111 
    112 class SearchViewlet(grok.Viewlet):
    113      grok.viewletmanager(MainArea)
    114      grok.view(Search)
    115      grok.context(University)
    116 
    117      def update(self, *args, **kw):
    118           #print "UPDATE: ", args, kw
    119           #print self.request.form
    120           form = self.request.form
    121           self.hitlist = []
    122           self.query = ''
    123           if not 'query' in form:
    124                return
    125           query = form['query']
    126           self.query = query
    127           cat = getUtility(ICatalog, name='courses_catalog')
    128           #print "CODES: ",  cat['code'].documentCount()
    129           #print "TITLES: ", cat['title'].documentCount()
    130           results = list(cat.searchResults(code=(query, query)))#
    131           #title=(query, query)))
    132           hitlist = []
    133           results = Query().searchResults(
    134                Eq(('courses_catalog', 'code'), query))
    135           for result in results:
    136                hitlist.append(CourseQueryResultItem(result, view=self.view))
    137 
    138           results = Query().searchResults(
    139                Text(('courses_catalog', 'title'), query))
    140          
    141           for result in results:
    142                hitlist.append(CourseQueryResultItem(result, view=self.view))
    143 
    144           self.hitlist = hitlist
Note: See TracChangeset for help on using the changeset viewer.