[Commits] (pavlov) even though we are exporting using clouds, we still export URLs to all itemrefs. Make the sync code check to make sure the items exist when it goes looking for them.

commits at osafoundation.org commits at osafoundation.org
Mon Aug 23 14:56:04 PDT 2004


Commit by: pavlov
Modified files:
chandler/parcels/osaf/framework/webdav/Dav.py 1.11 1.12
chandler/parcels/osaf/framework/webdav/Sync.py 1.12 1.13

Log message:
even though we are exporting using clouds, we still export URLs to all itemrefs.  Make the sync code check to make sure the items exist when it goes looking for them.
Skip non-ContentItems when iterating over the cloud


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

Index: chandler/parcels/osaf/framework/webdav/Dav.py
diff -u chandler/parcels/osaf/framework/webdav/Dav.py:1.11 chandler/parcels/osaf/framework/webdav/Dav.py:1.12
--- chandler/parcels/osaf/framework/webdav/Dav.py:1.11	Mon Aug 23 14:11:01 2004
+++ chandler/parcels/osaf/framework/webdav/Dav.py	Mon Aug 23 14:56:03 2004
@@ -53,10 +53,7 @@
 
     def get(self):
         """ returns a newly created Item """
-        try:
-            return Sync.getItem(self)
-        except NotFound:
-            return None
+        return Sync.getItem(self)
 
     def put(self, item):
         # add an entry here to say that we're already here
@@ -74,9 +71,16 @@
         else:
             item.sharedURL = self.url
 
+
+        contentItemKind = Globals.repository.findPath('//parcels/osaf/contentmodel/ContentItem')
+
         clouds = item.itsKind.getClouds('default')
         for cloud in clouds:
             for i in cloud.getItems(item):
+                # we only support publishing content items
+                if not i.isItemOf(contentItemKind):
+                    print 'Skipping %s -- Not a ContentItem' % (str(i))
+                    continue
                 defaultURL = self.url.join(i.itsUUID.str16())
                 durl = i.getAttributeValue('sharedURL', default=defaultURL)
                 i.sharedURL = durl

Index: chandler/parcels/osaf/framework/webdav/Sync.py
diff -u chandler/parcels/osaf/framework/webdav/Sync.py:1.12 chandler/parcels/osaf/framework/webdav/Sync.py:1.13
--- chandler/parcels/osaf/framework/webdav/Sync.py:1.12	Mon Aug 23 14:11:01 2004
+++ chandler/parcels/osaf/framework/webdav/Sync.py	Mon Aug 23 14:56:03 2004
@@ -5,6 +5,7 @@
 from repository.item.Item import Item
 from repository.schema.Kind import Kind
 
+import Dav
 import DAVItem as DAVItem
 
 
@@ -114,9 +115,10 @@
             for i in value:
                 if isinstance(i, Item):
                     defaultURL = dav.url.join(i.itsUUID.str16())
-                    durl = i.getAttributeValue('sharedURL', default=defaultURL)
-                    # mmm, recursion
-                    #DAV(durl).put(i)
+                    try:
+                        durl = i.getAttributeValue('sharedURL')
+                    except AttributeError:
+                        durl = defaultURL
                     listData += '<itemref>' + unicode(durl) + '</itemref>'
                 else:
                     #XXX fix this (Value is a PersistentList here??)
@@ -127,9 +129,14 @@
         elif acard == 'single':
             if isinstance(value, Item):
                 defaultURL = dav.url.join(value.itsUUID.str16())
-                durl = value.getAttributeValue('sharedURL', default=defaultURL)
-                #DAV(durl).put(value)
+                try:
+                    durl = value.getAttributeValue('sharedURL')
+                except AttributeError:
+                    durl = defaultURL
+                    print 'Cant export %s -- Not a ContentItem' % (str(value))
+                    
                 props += makePropString(name, namespace, '<itemref>%s</itemref>' % (unicode(durl)))
+                    
             else:
                 atypepath = "%s" % (atype.itsPath)
                 props += makePropString(name, namespace, atype.makeString(value))
@@ -177,7 +184,7 @@
 
 
 def syncFromServer(item, davItem):
-    from Dav import DAV
+    from Dav import DAV, NotFound
     kind = davItem.itsKind
 
     for (name, attr) in kind.iterAttributes(True):
@@ -204,8 +211,11 @@
             else:
                 raise Exception
             for node in nodes:
-                otherItem = DAV(node.content).get()
-                setfunc(name, otherItem)
+                try:
+                    otherItem = DAV(node.content).get()
+                    setfunc(name, otherItem)
+                except NotFound:
+                    print 'Cant access %s' % (node.content)
 
         else:
             if attr.cardinality == 'list':



More information about the Commits mailing list