Mercurial > hg > purlService
comparison restService/searcher.py @ 8:733d43b30a82
connection handling changed
searcher added
author | dwinter |
---|---|
date | Fri, 02 Nov 2012 11:34:23 +0100 |
parents | |
children | 5f5447b3a082 |
comparison
equal
deleted
inserted
replaced
7:78dd28ade713 | 8:733d43b30a82 |
---|---|
1 ''' | |
2 Created on 02.11.2012 | |
3 | |
4 @author: dwinter | |
5 ''' | |
6 | |
7 import web | |
8 import manageIndexMetaPURLs | |
9 | |
10 class searcher: | |
11 | |
12 def __init__(self): | |
13 self.md=manageIndexMetaPURLs.IndexMetaPURLManager() | |
14 | |
15 def GET(self): | |
16 | |
17 input = web.input() | |
18 | |
19 if not hasattr(input, 'q'): | |
20 return "usage: ?q=QUERYSTRING" | |
21 query = input.q | |
22 | |
23 purls=self.md.search(query) | |
24 | |
25 currentUrl = web.ctx.homepath | |
26 | |
27 if purls is None: | |
28 purls=[] | |
29 | |
30 ret="""<div class="results"><div class="purls_found_count">%s</div>"""%len(purls) | |
31 | |
32 for purl in purls: | |
33 ret+="""<div class="purls"><a href="%s">%s</a></div>"""%(currentUrl+"/purl/"+purl['purl'],purl['purl']) | |
34 | |
35 | |
36 web.header('Content-Type', 'text/html') | |
37 return ret+"</div>" | |
38 | |
39 | |
40 if __name__ == '__main__': | |
41 pass |