Changeset 4667 for waeup/branches/ulif-layout
- Timestamp:
- 5 Jan 2010, 09:50:36 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4661 r4667 6 6 from hurry.query.query import Query, Text 7 7 from waeup.browser import WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage 8 from waeup.catalog import search, search_context 8 9 from waeup.interfaces import (IUniversity, IWAeUPObject, IUserContainer, 9 10 IUserAccount, IFacultyContainer) … … 199 200 self.search_result = [] 200 201 if query is not None: 201 self.search_result = se lf.search_context(query)202 self.search_result = search_context(query) 202 203 print "RESULT: ", list(self.search_result) 203 204 204 def search_context(self, query):205 result = Query().searchResults(206 Eq(('students_catalog', 'name'), query)207 )208 return result209 210 from zope.interface import Interface211 from zope import schema212 213 class IQueryResultItem(Interface):214 url = schema.TextLine(215 title = u'URL that links to the found item')216 title = schema.TextLine(217 title = u'Title displayed in search results.')218 description = schema.Text(219 title = u'Longer description of the item found.')220 221 222 class QueryResultItem(object):223 grok.implements(IQueryResultItem)224 url = None225 title = None226 description = None227 228 def __init__(self, context, view):229 self.context = context230 self.url = view.url(context)231 self.title = context.title232 self.description = ''233 234 class CourseQueryResultItem(QueryResultItem):235 def __init__(self, context, view):236 self.context = context237 self.url = view.url(context)238 self.title = "COURSE: " + context.title239 self.description = 'code: %s' % context.code240 241 242 #from waeup.viewlets import Search, MainArea243 from hurry.query.query import Query, Text, Eq244 from zope.app.catalog.interfaces import ICatalog245 205 246 206 class SearchPage(WAeUPPage): … … 251 211 252 212 def update(self, *args, **kw): 253 #print "UPDATE: ", args, kw254 #print self.request.form255 213 form = self.request.form 256 214 self.hitlist = [] … … 260 218 query = form['query'] 261 219 self.query = query 262 cat = getUtility(ICatalog, name='courses_catalog') 263 #print "CODES: ", cat['code'].documentCount() 264 #print "TITLES: ", cat['title'].documentCount() 265 results = list(cat.searchResults(code=(query, query)))# 266 #title=(query, query))) 267 hitlist = [] 268 results = Query().searchResults( 269 Eq(('courses_catalog', 'code'), query)) 270 for result in results: 271 hitlist.append(CourseQueryResultItem(result, view=self)) 272 273 results = Query().searchResults( 274 Text(('courses_catalog', 'title'), query)) 275 276 for result in results: 277 hitlist.append(CourseQueryResultItem(result, view=self)) 278 279 self.hitlist = hitlist 220 self.hitlist = search(query=self.query, view=self) 221 return 280 222 281 223
Note: See TracChangeset for help on using the changeset viewer.