view restService/searcher.py @ 12:0287aed01f2b

config and minor bugs
author dwinter
date Tue, 06 Nov 2012 08:41:18 +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