view restService/searcher.py @ 17:64d6ac1a1354

parameter for search changed
author dwinter
date Fri, 16 Nov 2012 15:26:05 +0100
parents 5f5447b3a082
children cf4503528b5e
line wrap: on
line source

'''
Created on 02.11.2012

@author: dwinter
'''

import web
import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs

class searcher:
    
    def __init__(self):
        self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
    
    def GET(self):
        
        input = web.input()
        
        if not hasattr(input, 'q'):
            return "usage: ?q=QUERYSTRING"
        query = input.q
        
        purls=self.md.search(query)
        
        currentUrl = web.ctx.homepath
        
        if purls is None:
            purls=[]
        
        ret="""<div class="results"><div class="purls_found_count">%s</div>"""%len(purls)
        
        for purl in purls:
            ret+="""<div class="purls"><a href="%s">%s</a></div>"""%(currentUrl+"/purl/"+purl['purl'],purl['purl'])
        
        
        web.header('Content-Type', 'text/html')
        return ret+"</div>"
        
         
if __name__ == '__main__':
    pass