diff restService/searcher.py @ 8:733d43b30a82

connection handling changed searcher added
author dwinter
date Fri, 02 Nov 2012 11:34:23 +0100
parents
children 5f5447b3a082
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/restService/searcher.py	Fri Nov 02 11:34:23 2012 +0100
@@ -0,0 +1,41 @@
+'''
+Created on 02.11.2012
+
+@author: dwinter
+'''
+
+import web
+import 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
\ No newline at end of file