[Commits] (alecf) after talking with john - unify the "items" list attribute and the itemcollection to greatly simplify RSS item management

commits at osafoundation.org commits at osafoundation.org
Tue Feb 15 14:21:55 PST 2005


Commit by: alecf
Modified files:
chandler/parcels/osaf/views/main/Main.py 1.143 1.144
chandler/parcels/osaf/examples/zaobao/parcel.xml 1.36 1.37
chandler/parcels/osaf/examples/zaobao/RSSData.py 1.30 1.31

Log message:
after talking with john - unify the "items" list attribute and the itemcollection to greatly simplify RSS item management

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.143&r2=text&tr2=1.144
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/examples/zaobao/parcel.xml.diff?r1=text&tr1=1.36&r2=text&tr2=1.37
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/examples/zaobao/RSSData.py.diff?r1=text&tr1=1.30&r2=text&tr2=1.31

Index: chandler/parcels/osaf/examples/zaobao/parcel.xml
diff -u chandler/parcels/osaf/examples/zaobao/parcel.xml:1.36 chandler/parcels/osaf/examples/zaobao/parcel.xml:1.37
--- chandler/parcels/osaf/examples/zaobao/parcel.xml:1.36	Tue Feb 15 11:23:13 2005
+++ chandler/parcels/osaf/examples/zaobao/parcel.xml	Tue Feb 15 14:21:53 2005
@@ -103,18 +103,10 @@
   
     <Attribute itsName="items">
       <displayName>Items</displayName>
-      <cardinality>list</cardinality>
-      <type itemref="doc:RSSItem"/>
-      <inverseAttribute itemref="doc:RSSItem/channel"/>
+      <cardinality>single</cardinality>
+      <type itemref="content:ItemCollection"/>
     </Attribute>
     
-    <Attribute itsName="itemCollections">
-        <displayName>Item Collections</displayName>
-        <cardinality>list</cardinality>
-        <type itemref="content:ItemCollection"/>
-        <initialValue/>
-    </Attribute>
-
     <!-- Actual attribute uses -->
     
     <!-- RSSChannel attributes -->
@@ -126,7 +118,6 @@
 
     <attributes itemref="doc:RSSChannel/isUnread"/>
     <attributes itemref="doc:RSSChannel/items"/>
-    <attributes itemref="doc:RSSChannel/itemCollections"/>
 
     <!-- These attributes are shared between RSSChannel and RSSItem -->
     <attributes itemref="doc:link"/>
@@ -189,7 +180,6 @@
       <displayName>Channel</displayName>
       <cardinality>single</cardinality>
       <type itemref="doc:RSSChannel"/>
-      <inverseAttribute itemref="doc:RSSChannel/items"/>
     </Attribute>
 
     <Attribute itsName="content">

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.143 chandler/parcels/osaf/views/main/Main.py:1.144
--- chandler/parcels/osaf/views/main/Main.py:1.143	Tue Feb 15 11:23:13 2005
+++ chandler/parcels/osaf/views/main/Main.py	Tue Feb 15 14:21:52 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.143 $"
-__date__ = "$Date: 2005/02/15 19:23:13 $"
+__version__ = "$Revision: 1.144 $"
+__date__ = "$Date: 2005/02/15 22:21:52 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -367,15 +367,9 @@
                 # create the zaobao channel
                 channel = osaf.examples.zaobao.RSSData.NewChannelFromURL(view=self.itsView, url=url, update=True)
                 
-                # hook up a new collection for the sidebar
-                collKind = self.itsView.findPath("//parcels/osaf/contentmodel/ItemCollection")
-                sidebarCollection = collKind.newItem(None, None)
-                sidebarCollection.displayName = channel.displayName
-                channel.addCollection(sidebarCollection)
-                
                 # now post the new collection to the sidebar
                 mainView = Globals.views[0]
-                mainView.postEventByName ('AddToSidebarWithoutCopying', {'items': [sidebarCollection]})
+                mainView.postEventByName ('AddToSidebarWithoutCopying', {'items': [channel.items]})
                 self.itsView.commit()
             except:
                 application.dialogs.Util.ok(wx.GetApp().mainFrame, "New Channel Error", 

Index: chandler/parcels/osaf/examples/zaobao/RSSData.py
diff -u chandler/parcels/osaf/examples/zaobao/RSSData.py:1.30 chandler/parcels/osaf/examples/zaobao/RSSData.py:1.31
--- chandler/parcels/osaf/examples/zaobao/RSSData.py:1.30	Tue Feb 15 11:23:13 2005
+++ chandler/parcels/osaf/examples/zaobao/RSSData.py	Tue Feb 15 14:21:53 2005
@@ -1,5 +1,5 @@
-__revision__  = "$Revision: 1.30 $"
-__date__      = "$Date: 2005/02/15 19:23:13 $"
+__revision__  = "$Revision: 1.31 $"
+__date__      = "$Date: 2005/02/15 22:21:53 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -41,7 +41,7 @@
 
     channel = RSSChannel(view=view)
     channel.url = url
-
+    
     if update:
         try:
             channel.Update(data)
@@ -57,7 +57,8 @@
 
     def __init__(self, name=None, parent=None, kind=None, view=None):
         super(RSSChannel, self).__init__(name, parent, kind, view)
-        self.items = []
+        self.items = ItemCollection(view=view)
+        
 
     def Update(self, data=None):
         etag = self.getAttributeValue('etag', default=None)
@@ -79,36 +80,27 @@
 
         # if the feed is bad, raise the sax exception
         try:
-            if data['bozo'] == 1:
-                raise data['bozo_exception']
+            if data.bozo and (data.bozo_exception != feedparser.CharacterEncodingOverride):
+                raise data.bozo_exception
         except KeyError:
             return
 
         self._DoChannel(data['channel'])
         self._DoItems(data['items'])
-
-    def addCollection(self, collection):
-        """
-            Add a new collection, and update it with the list of all known items to date
-        """
-        for rssItem in self.items:
-            collection.add(rssItem)
-            
-        self.itemCollections.append(collection)
             
     def addRSSItem(self, rssItem):
         """
             Add a single item, and add it to any listening collections
         """
-        self.addValue('items', rssItem)
-        for collection in self.itemCollections:
-            collection.add(rssItem)
+        rssItem.channel = self
+        self.items.add(rssItem)
         
 
     def _DoChannel(self, data):
         # fill in the item
         attrs = {'title':'displayName'}
         SetAttributes(self, data, attrs)
+        self.items.displayName = self.displayName
 
         attrs = ['link', 'description', 'copyright', 'category', 'language']
         # @@@MOR attrs = ['link', 'description', 'copyright', 'creator', 'category', 'language']



More information about the Commits mailing list