annotate restService/searcher.py @ 17:64d6ac1a1354

parameter for search changed
author dwinter
date Fri, 16 Nov 2012 15:26:05 +0100
parents 5f5447b3a082
children cf4503528b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
1 '''
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
2 Created on 02.11.2012
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
3
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
4 @author: dwinter
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
5 '''
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
6
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
7 import web
9
5f5447b3a082 repackaging
dwinter
parents: 8
diff changeset
8 import managePurls.manageIndexMetaPURLs as manageIndexMetaPURLs
8
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
9
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
10 class searcher:
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
11
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
12 def __init__(self):
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
13 self.md=manageIndexMetaPURLs.IndexMetaPURLManager()
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
14
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
15 def GET(self):
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
16
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
17 input = web.input()
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
18
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
19 if not hasattr(input, 'q'):
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
20 return "usage: ?q=QUERYSTRING"
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
21 query = input.q
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
22
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
23 purls=self.md.search(query)
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
24
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
25 currentUrl = web.ctx.homepath
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
26
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
27 if purls is None:
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
28 purls=[]
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
29
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
30 ret="""<div class="results"><div class="purls_found_count">%s</div>"""%len(purls)
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
31
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
32 for purl in purls:
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
33 ret+="""<div class="purls"><a href="%s">%s</a></div>"""%(currentUrl+"/purl/"+purl['purl'],purl['purl'])
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
34
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
35
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
36 web.header('Content-Type', 'text/html')
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
37 return ret+"</div>"
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
38
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
39
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
40 if __name__ == '__main__':
733d43b30a82 connection handling changed
dwinter
parents:
diff changeset
41 pass