Laurent Mignon created CMIS-996:
-----------------------------------
Summary: BrowserBinding getObjecyByPath: unicode is not supported
by urllib.quote
Key: CMIS-996
URL: https://issues.apache.org/jira/browse/CMIS-996
Project: Chemistry
Issue Type: Bug
Components: python-cmislib
Reporter: Laurent Mignon
Assignee: Jeff Potts
The browser binding on the trunk doesn't support multi valued values for
properties.
{code}
diff --git a/src/cmislib/browser/binding.py b/src/cmislib/browser/binding.py
index b340eda..8565be0 100644
--- a/src/cmislib/browser/binding.py
+++ b/src/cmislib/browser/binding.py
@@ -352,13 +352,7 @@ class BrowserCmisObject(object):
updateUrl = self._repository.getRootFolderUrl() + "?objectId=" +
self.id
props = {"cmisaction": "update"}
-
- propCount = 0
- for prop in properties:
- props["propertyId[%s]" % propCount] = prop
- props["propertyValue[%s]" % propCount] = properties[prop]
- propCount += 1
-
+ setProps(properties, props, initialIndex=0)
# invoke the URL
result = self._cmisClient.binding.post(updateUrl.encode('utf-8'),
urlencode(props),
@@ -1325,14 +1319,11 @@ class BrowserRepository(object):
props["propertyId[1]"] = "cmis:objectTypeId"
if properties.has_key('cmis:objectTypeId'):
props["propertyValue[1]"] = properties['cmis:objectTypeId']
+ del properties['cmis:objectTypeId']
else:
props["propertyValue[1]"] = "cmis:document"
- propCount = 2
- for prop in properties:
- props["propertyId[%s]" % propCount] = prop
- props["propertyValue[%s]" % propCount] = properties[prop]
- propCount += 1
+ setProps(properties, props, initialIndex=2)
contentType, body = encode_multipart_formdata(props, contentFile,
contentType)
@@ -1775,10 +1766,7 @@ class BrowserDocument(BrowserCmisObject):
props.update(kwargs)
propCount = 0
properties = properties or {}
- for key, value in properties.iteritems():
- props["propertyId[%s]" % propCount] = key
- props["propertyValue[%s]" % propCount] = value
- propCount += 1
+ setProps(properties, props, initialIndex=0)
ciUrl = self._repository.getRootFolderUrl() + "?objectId=" + self.id +
"&cmisaction=checkin"
@@ -2050,11 +2038,7 @@ class BrowserFolder(BrowserCmisObject):
else:
props["propertyValue[1]"] = "cmis:folder"
- propCount = 2
- for key, val in properties.items():
- props["propertyId[%s]" % propCount] = key
- props["propertyValue[%s]" % propCount] = val
- propCount += 1
+ setProps(properties, props, initialIndex=2)
# invoke the URL
result = self._cmisClient.binding.post(createFolderUrl.encode('utf-8'),
@@ -3028,6 +3012,24 @@ class BrowserCmisId(str):
pass
+def setProps(properties, props, initialIndex=0):
+ """
+ Transform key, value from properties into props list items in the format
+ expected by the HTTP POST request
+ """
+ i = initialIndex
+ for key, val in properties.items():
+ props["propertyId[%s]" % i] = key
+ if hasattr(val, '__iter__'):
+ j = 0
+ for v in val:
+ props["propertyValue[%s][%s]" % (i, j)] = v
+ j += 1
+ else:
+ props["propertyValue[%s]" % i] = val
+ i += 1
+
+
def getSpecializedObject(obj, **kwargs):
"""
{code}
https://github.com/lmignon/python-cmislib/commit/04c944398531691b86c39cf3160cd61c1553a137
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)