chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r1595244 - in /chemistry/cmislib/trunk/src/cmislib: browser/binding.py util.py
Date Fri, 16 May 2014 15:53:38 GMT
Author: jpotts
Date: Fri May 16 15:53:38 2014
New Revision: 1595244

URL: http://svn.apache.org/r1595244
Log:
implement cmislib browser binding queries

Modified:
    chemistry/cmislib/trunk/src/cmislib/browser/binding.py
    chemistry/cmislib/trunk/src/cmislib/util.py

Modified: chemistry/cmislib/trunk/src/cmislib/browser/binding.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/cmislib/browser/binding.py?rev=1595244&r1=1595243&r2=1595244&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/cmislib/browser/binding.py (original)
+++ chemistry/cmislib/trunk/src/cmislib/browser/binding.py Fri May 16 15:53:38 2014
@@ -1096,7 +1096,7 @@ class BrowserRepository(object):
         """
 
         # build the CMIS query XML that we're going to POST
-        queryUrl = self.getRepositoryUrl() + "?cmisaction=query&q=" + statement
+        queryUrl = self.getRepositoryUrl() + "?cmisaction=query&q=" + quote(statement)
 
         # do the POST
         result = self._cmisClient.binding.post(queryUrl.encode('utf-8'),
@@ -1107,7 +1107,7 @@ class BrowserRepository(object):
                                                **kwargs)
 
         # return the result set
-        return BrowserResultSet(self._cmisClient, self, result)
+        return BrowserResultSet(self._cmisClient, self, result, serializer=ResultsSerializer())
 
 
     def getContentChanges(self, **kwargs):
@@ -2995,6 +2995,18 @@ def encode_multipart_formdata(fields, fi
     return content_type, body
 
 
+class ResultsSerializer(object):
+    def fromJSON(self, client, repo, jsonObj):
+        entries = []
+        for obj in jsonObj['results']:
+            cmisObject = getSpecializedObject(BrowserCmisObject(client,
+                                                                repo,
+                                                                data=obj))
+            entries.append(cmisObject)
+
+        return entries
+
+
 class ChildrenSerializer(object):
     def fromJSON(self, client, repo, jsonObj):
         entries = []

Modified: chemistry/cmislib/trunk/src/cmislib/util.py
URL: http://svn.apache.org/viewvc/chemistry/cmislib/trunk/src/cmislib/util.py?rev=1595244&r1=1595243&r2=1595244&view=diff
==============================================================================
--- chemistry/cmislib/trunk/src/cmislib/util.py (original)
+++ chemistry/cmislib/trunk/src/cmislib/util.py Fri May 16 15:53:38 2014
@@ -101,7 +101,12 @@ def parsePropValueByType(value, typeName
             return 0
     elif typeName == 'decimal':
         if value:
-            return float(value)
+            # search result relevance is returning as an arrary of decimals
+            # in the browser binding for some reason
+            if isinstance(value, list):
+                return float(value[0])
+            else:
+                return float(value)
         else:
             return 0.0
     elif typeName == 'datetime':



Mime
View raw message