# HG changeset patch # User dwinter # Date 1367346770 -7200 # Node ID 245294b18a1dbe9c5247073ae3db74b5bdbde606 # Parent f845502cf73aeb30bbfba4280f9215b586c1b7fd search modified diff -r f845502cf73a -r 245294b18a1d zopePubmanConnector.py --- 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)