changeset 5:245294b18a1d

search modified
author dwinter
date Tue, 30 Apr 2013 20:32:50 +0200
parents f845502cf73a
children 49abb91d6c6a
files zopePubmanConnector.py
diffstat 1 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/zopePubmanConnector.py	Tue Apr 30 19:45:29 2013 +0200
+++ b/zopePubmanConnector.py	Tue Apr 30 20:32:50 2013 +0200
@@ -103,7 +103,7 @@
         return ret
     
     
-    def search(self,values,exact=False):
+    def search(self,values={},exact=False,limit=None,contexts=None):
         
         """search pubman
         @values map mit field->value
@@ -118,6 +118,10 @@
         cn = self.connectorString+"cqlQuery=%s&"
         cn +="exportFormat=APA&outputFormat=snippet&language=all&sortKeys=escidoc.any-dates&sortOrder=descending"
         
+        if limit:
+            cn+="&maximumRecords=%s"%limit
+  
+      
        
        
         querys = []
@@ -141,7 +145,25 @@
             querys.append("%s=%%22%s%%22"%(searchField,value))
         
         
-        query=" AND ".join(querys)
+        query="+AND+".join(querys)
+        
+        
+        if contexts: # einscbraenken auf contexte
+            
+            if isinstance(contexts, str):
+                contexts=[contexts]
+            
+            ctxquerys=[]
+            for context in contexts:
+                ctxquerys.append("escidoc.context.objid=%%22%s%%22"%(context))
+                
+            ctxquery="+OR+".join(ctxquerys)
+            
+            if query!="":
+                query=query+"AND (%s)"%ctxquery
+            else:
+                query="(%s)"%ctxquery
+                
         h = httplib2.Http()
        
         logging.debug(cn%query)