[Commits] (capps) workaround for bug 1238: create zaobao items and content items in separate repository containers to avoid change conflicts

commits at osafoundation.org commits at osafoundation.org
Fri Feb 13 18:54:51 PST 2004


Commit by: capps
Modified files:
osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py 1.10 1.11

Log message:
workaround for bug 1238: create zaobao items and content items in separate repository containers to avoid change conflicts


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py.diff?r1=text&tr1=1.10&r2=text&tr2=1.11

Index: osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py
diff -u osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py:1.10 osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py:1.11
--- osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py:1.10	Wed Feb 11 18:39:40 2004
+++ osaf/chandler/Chandler/parcels/OSAF/examples/zaobao/RSSData.py	Fri Feb 13 18:54:20 2004
@@ -1,5 +1,5 @@
-__revision__  = "$Revision: 1.10 $"
-__date__      = "$Date: 2004/02/12 02:39:40 $"
+__revision__  = "$Revision: 1.11 $"
+__date__      = "$Date: 2004/02/14 02:54:20 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -20,17 +20,47 @@
     def __init__(self, name, parent, kind):
         Parcel.__init__(self, name, parent, kind)
 
-    def _setUUIDs(self):
+    def _setUUIDs(self, parent):
+
+        # hackery to avoid threading conflicts
+        ZaoBaoParcel.RSSItemParentID = parent.getUUID()
+        
         ZaoBaoParcel.RSSChannelKindID = self.find('RSSChannel').getUUID()
         ZaoBaoParcel.RSSItemKindID = self.find('RSSItem').getUUID()
 
     def onItemLoad(self):
         super(ZaoBaoParcel, self).onItemLoad()
-        self._setUUIDs()
+
+        # @@@ hackery to avoid threading conflicts
+        repository = self.getRepository()
+        parent = repository.find('//userdata/zaobaoitems')
+        
+        self._setUUIDs(parent)
 
     def startupParcel(self):
         super(ZaoBaoParcel, self).startupParcel()
-        self._setUUIDs()
+
+        # @@@ hackery to avoid threading conflicts
+        # Create a separate parent for RSSItems
+        repository = self.getRepository()
+        parent = repository.find('//userdata/zaobaoitems')
+        if not parent:
+            itemKind = repository.find('//Schema/Core/Item')
+            userdata = repository.find('//userdata')
+            if not userdata:
+                userdata = itemKind.newItem('userdata', repository)
+            parent = itemKind.newItem('zaobaoitems', userdata)
+        
+        self._setUUIDs(parent)
+
+    # @@@ hackery to avoid threading conflicts
+    # Keep track of a separate parent for RSSItems
+
+    def getRSSItemParent(cls):
+        assert cls.RSSItemParentID, "ZaoBaoParcel not yet loaded"
+        return Globals.repository[cls.RSSItemParentID]
+
+    getRSSItemParent = classmethod(getRSSItemParent)
 
     def getRSSChannelKind(cls):
         assert cls.RSSChannelKindID, "ZaoBaoParcel not yet loaded"
@@ -90,6 +120,9 @@
 
 class RSSChannel(ContentItem):
     def __init__(self, name=None, parent=None, kind=None):
+        # @@@ parent is hackery to avoid threading conflicts
+        if not parent:
+            parent = ZaoBaoParcel.getRSSItemParent()
         if not kind:
             kind = ZaoBaoParcel.getRSSChannelKind()
         super(RSSChannel, self).__init__(name, parent, kind)
@@ -144,6 +177,9 @@
 ##
 class RSSItem(ContentItem):
     def __init__(self, name=None, parent=None, kind=None):
+        # @@@ parent is hackery to avoid threading conflicts
+        if not parent:
+            parent = ZaoBaoParcel.getRSSItemParent()
         if not kind:
             kind = ZaoBaoParcel.getRSSItemKind()
         super(RSSItem, self).__init__(name, parent, kind)



More information about the Commits mailing list