chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpo...@apache.org
Subject svn commit: r967147 - in /incubator/chemistry/cmislib/trunk/src: cmislib.egg-info/SOURCES.txt cmislib/model.py
Date Fri, 23 Jul 2010 16:03:36 GMT
Author: jpotts
Date: Fri Jul 23 16:03:36 2010
New Revision: 967147

URL: http://svn.apache.org/viewvc?rev=967147&view=rev
Log:
Fix for CMIS-239: Support for getting and setting multi-value props. Tested against OpenCMIS
in-memory atom.

Modified:
    incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt
    incubator/chemistry/cmislib/trunk/src/cmislib/model.py

Modified: incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt?rev=967147&r1=967146&r2=967147&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt (original)
+++ incubator/chemistry/cmislib/trunk/src/cmislib.egg-info/SOURCES.txt Fri Jul 23 16:03:36
2010
@@ -2,7 +2,6 @@
 .pydevproject
 LICENSE.txt
 MANIFEST.in
-PKG-INFO
 README.txt
 setup.cfg
 setup.py
@@ -32,38 +31,6 @@ src/data/types.chemistry.xml
 src/data/types.filenet.xml
 src/data/types.xml
 src/data/workingCopy.xml
-src/doc/build/about.html
-src/doc/build/code.html
-src/doc/build/devguide.html
-src/doc/build/docs.html
-src/doc/build/examples.html
-src/doc/build/genindex.html
-src/doc/build/index.html
-src/doc/build/install.html
-src/doc/build/modindex.html
-src/doc/build/objects.inv
-src/doc/build/sample-data.html
-src/doc/build/search.html
-src/doc/build/searchindex.js
-src/doc/build/tests.html
-src/doc/build/_sources/about.txt
-src/doc/build/_sources/code.txt
-src/doc/build/_sources/devguide.txt
-src/doc/build/_sources/docs.txt
-src/doc/build/_sources/examples.txt
-src/doc/build/_sources/index.txt
-src/doc/build/_sources/install.txt
-src/doc/build/_sources/sample-data.txt
-src/doc/build/_sources/tests.txt
-src/doc/build/_static/basic.css
-src/doc/build/_static/default.css
-src/doc/build/_static/doctools.js
-src/doc/build/_static/file.png
-src/doc/build/_static/jquery.js
-src/doc/build/_static/minus.png
-src/doc/build/_static/plus.png
-src/doc/build/_static/pygments.css
-src/doc/build/_static/searchtools.js
 src/doc/src/Makefile
 src/doc/src/about.rst
 src/doc/src/code.rst

Modified: incubator/chemistry/cmislib/trunk/src/cmislib/model.py
URL: http://svn.apache.org/viewvc/incubator/chemistry/cmislib/trunk/src/cmislib/model.py?rev=967147&r1=967146&r2=967147&view=diff
==============================================================================
--- incubator/chemistry/cmislib/trunk/src/cmislib/model.py (original)
+++ incubator/chemistry/cmislib/trunk/src/cmislib/model.py Fri Jul 23 16:03:36 2010
@@ -1773,9 +1773,17 @@ class CmisObject(object):
                 if node.childNodes and \
                    node.getElementsByTagNameNS(CMIS_NS, 'value')[0] and \
                    node.getElementsByTagNameNS(CMIS_NS, 'value')[0].childNodes:
-                    propertyValue = parsePropValue(
-                       node.getElementsByTagNameNS(CMIS_NS, 'value')[0].childNodes[0].data,
-                       node.localName)
+                    valNodeList = node.getElementsByTagNameNS(CMIS_NS, 'value')
+                    if (len(valNodeList) == 1):
+                        propertyValue = parsePropValue(valNodeList[0].
+                                                       childNodes[0].data,
+                                                       node.localName)
+                    else:
+                        propertyValue = []
+                        for valNode in valNodeList:
+                            propertyValue.append(parsePropValue(valNode.
+                                                       childNodes[0].data,
+                                                       node.localName))
                 else:
                     propertyValue = None
                 self._properties[propertyName] = propertyValue
@@ -2173,34 +2181,76 @@ class CmisObject(object):
                 I could do a lookup to the type definition, but that doesn't
                 seem worth the performance hit
                 """
-                if isinstance(propValue, CmisId):
+                propType = type(propValue)
+                isList = False
+                if (propType == list):
+                    propType = type(propValue[0])
+                    isList = True
+
+                if (propType == CmisId):
                     propElementName = 'cmis:propertyId'
-                    propValueStr = propValue
-                elif isinstance(propValue, str):
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(val)
+                    else:
+                        propValueStrList = [propValue]
+                elif (propType == str):
                     propElementName = 'cmis:propertyString'
-                    propValueStr = propValue
-                elif isinstance(propValue, datetime.datetime):
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(val)
+                    else:
+                        propValueStrList = [propValue]
+                elif (propType == datetime.datetime):
                     propElementName = 'cmis:propertyDateTime'
-                    propValueStr = propValue.isoformat()
-                elif isinstance(propValue, bool):
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(val.isoformat())
+                    else:
+                        propValueStrList = [propValue.isoformat()]
+                elif (propType == bool):
                     propElementName = 'cmis:propertyBoolean'
-                    propValueStr = str(propValue).lower()
-                elif isinstance(propValue, int):
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(str(val).lower())
+                    else:
+                        propValueStrList = [str(propValue).lower()]
+                elif (propType == int):
                     propElementName = 'cmis:propertyInteger'
-                    propValueStr = str(propValue)
-                elif isinstance(propValue, float):
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(str(val))
+                    else:
+                        propValueStrList = [str(propValue)]
+                elif (propType == float):
                     propElementName = 'cmis:propertyDecimal'
-                    propValueStr = str(propValue)
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(str(val))
+                    else:
+                        propValueStrList = [str(propValue)]
                 else:
                     propElementName = 'cmis:propertyString'
-                    propValueStr = str(propValue)
+                    if isList:
+                        propValueStrList = []
+                        for val in propValue:
+                            propValueStrList.append(str(val))
+                    else:
+                        propValueStrList = [str(propValue)]
 
                 propElement = entryXmlDoc.createElementNS(CMIS_NS, propElementName)
                 propElement.setAttribute('propertyDefinitionId', propName)
-                valElement = entryXmlDoc.createElementNS(CMIS_NS, 'cmis:value')
-                val = entryXmlDoc.createTextNode(propValueStr)
-                valElement.appendChild(val)
-                propElement.appendChild(valElement)
+                for val in propValueStrList:
+                    valElement = entryXmlDoc.createElementNS(CMIS_NS, 'cmis:value')
+                    valText = entryXmlDoc.createTextNode(val)
+                    valElement.appendChild(valText)
+                    propElement.appendChild(valElement)
                 propsElement.appendChild(propElement)
 
         return entryXmlDoc



Mime
View raw message