Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 85220200BA4 for ; Fri, 9 Sep 2016 17:34:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 83D62160AC2; Fri, 9 Sep 2016 15:34:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C73E2160ACA for ; Fri, 9 Sep 2016 17:34:22 +0200 (CEST) Received: (qmail 73703 invoked by uid 500); 9 Sep 2016 15:34:22 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 73633 invoked by uid 99); 9 Sep 2016 15:34:22 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2016 15:34:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id BE2AC2C1B79 for ; Fri, 9 Sep 2016 15:34:21 +0000 (UTC) Date: Fri, 9 Sep 2016 15:34:21 +0000 (UTC) From: "Laurent Mignon (JIRA)" To: dev@chemistry.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CMIS-979) Allow to use multi valued values in properties when using the Browser Binding MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 09 Sep 2016 15:34:23 -0000 [ https://issues.apache.org/jira/browse/CMIS-979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15477345#comment-15477345 ] Laurent Mignon commented on CMIS-979: ------------------------------------- [~gagravarr] Thank you for the answer. The last time I've looked to the github repository it seemed to be un synced with svn. Am I wrong? Regards > Allow to use multi valued values in properties when using the Browser Binding > ----------------------------------------------------------------------------- > > Key: CMIS-979 > URL: https://issues.apache.org/jira/browse/CMIS-979 > 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)