[Commits] (pavlov) fixing exporting/importing of attributs with literal values and cardinality of list

commits at osafoundation.org commits at osafoundation.org
Thu Aug 19 15:34:44 PDT 2004


Commit by: pavlov
Modified files:
chandler/parcels/osaf/framework/webdav/Sync.py 1.7 1.8

Log message:
fixing exporting/importing of attributs with literal values and cardinality of list


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/webdav/Sync.py.diff?r1=text&tr1=1.7&r2=text&tr2=1.8

Index: chandler/parcels/osaf/framework/webdav/Sync.py
diff -u chandler/parcels/osaf/framework/webdav/Sync.py:1.7 chandler/parcels/osaf/framework/webdav/Sync.py:1.8
--- chandler/parcels/osaf/framework/webdav/Sync.py:1.7	Thu Aug 19 14:17:51 2004
+++ chandler/parcels/osaf/framework/webdav/Sync.py	Thu Aug 19 15:34:42 2004
@@ -113,8 +113,7 @@
                     DAV(durl).put(i)
                     listData += '<itemref>' + unicode(durl) + '</itemref>'
                 else:
-                    # XXX TODO add literal list stuff here
-                    pass
+                    listData += '<value>' + value + '</value>'
             props += makePropString(name, namespace, listData)
 
         elif acard == 'single':
@@ -156,6 +155,18 @@
 
 
 
+def nodesFromXml(data):
+    """
+    Given a chunk of text that is a flat xml tree like:
+      '<foo/><foo/><foo/>'
+    parse it and return a list of the nodes
+    """
+    xmlgoop = davlib.XML_DOC_HEADER + \
+              '<doc>' + data + '</doc>'
+    doc = libxml2.parseDoc(xmlgoop)
+    nodes = doc.xpathEval('/doc/*')
+    return nodes
+
 
 def syncFromServer(item, davItem):
     from Dav import DAV
@@ -173,13 +184,7 @@
         if isinstance(attr.type, Kind):
             # time for some xml parsing! yum!
 
-            # given a chunk of text that is a flat xml tree like:
-            # "<foo/><foo/><foo/>"
-            # parse it and return a list of the nodes
-            xmlgoop = davlib.XML_DOC_HEADER + \
-                      '<doc>' + value + '</doc>'
-            doc = libxml2.parseDoc(xmlgoop)
-            nodes = doc.xpathEval('/doc/*')
+            nodes = nodesFromXml(value)
 
             if attr.cardinality == 'list':
                 setfunc = item.addValue
@@ -195,8 +200,14 @@
                 setfunc(name, otherItem)
 
         else:
-            print 'Got.....: ', value
-            item.setAttributeValue(name, attr.type.makeValue(value))
+            if attr.cardinality == 'list':
+                nodes = nodesFromXml(value)
+                for node in nodes:
+                    item.addValue(name, node.content)
+                    print 'Got.....: ', value
+            elif attr.cardinality == 'single':
+                print 'Got.....: ', value
+                item.setAttributeValue(name, attr.type.makeValue(value))
 
 
     #
@@ -205,15 +216,7 @@
     if item.isItemOf(Globals.repository.findPath('//parcels/osaf/contentmodel/ItemCollection')):
         value = davItem._getAttribute('results', '//special/case')
 
-        # time for some xml parsing! yum!
-
-        # given a chunk of text that is a flat xml tree like:
-        # "<foo/><foo/><foo/>"
-        # parse it and return a list of the nodes
-        xmlgoop = davlib.XML_DOC_HEADER + \
-                  '<doc>' + value + '</doc>'
-        doc = libxml2.parseDoc(xmlgoop)
-        nodes = doc.xpathEval('/doc/*')
+        nodes = nodesFromXml(value)
 
         serverCollectionResults = []
         for node in nodes:



More information about the Commits mailing list