# $Id$ # $URL$ import searchform, resultlist, drilldown websiteConfig = configs['website'] logger = logging.getLogger('meresco.search') logger.debug("Starting logger") def main(headers={}, arguments={}, *args, **kwargs): query = '' httpQuery = '' if kwargs['query']: logger.debug('kwargs query: ' + kwargs['query']) if ('query' in (arguments)): query = arguments.get('query', [''])[0] logger.debug ( infra.prpt('QUERY', arguments)) httpQuery = arguments.get('query', [''])[0] httpQuery = escapeHtml(httpQuery) sortBy = sortDescending = None sortKeys = arguments.get('sortKeys', [''])[0] if not sortKeys: sortKeys = any.configuration().get('defaultSortKeys', None) if sortKeys: sortBy, ignored, sortDescending = sortKeys.split(',') sortDescending = sortDescending == '1' drilldownArguments = arguments.get('drilldown', []) extra = arguments.get('extra', []) # parsetree wordt doorgegeven aan search engine via de call executeCQL # cqlQuery is de serialisatie die gebruikt wordt voor RSS parsetree, cqlQuery = any.parseQuery(query, drilldownArguments, extra) # De start en stop argumenten bepalen het begin en eind record welke worden teruggegeven. # De +10 in de stop is dus de batchgrootte. t0 = time() offset = int(arguments.get('offset', ['0'])[0]) total, recordIds = any.executeCQL(cqlAbstractSyntaxTree=parsetree, start=offset, stop=offset+10, sortBy=sortBy, sortDescending=sortDescending) docset = any.docsetFromQuery(cqlAbstractSyntaxTree=parsetree) duration = time() - t0 # strings messageOfTheDay = websiteConfig.get('messageOfTheDay', section = 'userFeedback') rssLink = '%s/rss?%s' % (any.configuration().get('baseURL', ''), urlencode({'query': cqlQuery})) rssImage = '/files/' + websiteConfig.get('rss', section='images') # generator objects drilldowns = drilldown.main(total=total, docset=docset, arguments=arguments, *args, **kwargs) searchForm = searchform.main(arguments=arguments, *args, **kwargs) resultList = resultlist.main(total=total, recordIds=recordIds, docset=docset, duration=duration, cqlQuery=cqlQuery, httpQuery = httpQuery, arguments=arguments, *args, **kwargs) yield backtick('search.template', { 'drilldowns': drilldowns, 'messageOfTheDay': messageOfTheDay, 'rssLink': rssLink, 'rssImage': rssImage, 'searchForm': searchForm, 'resultList': resultList })