[Zope3-checkins] CVS: Products3/NewsSite - newssite.py:1.2
Axel Bringenberg
A.Bringenberg@srz-berlin.de
Wed, 26 Mar 2003 09:56:14 -0500
Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv22246
Modified Files:
newssite.py
Log Message:
- added method that lists available news items
=== Products3/NewsSite/newssite.py 1.1 => 1.2 ===
--- Products3/NewsSite/newssite.py:1.1 Wed Mar 26 05:47:53 2003
+++ Products3/NewsSite/newssite.py Wed Mar 26 09:56:14 2003
@@ -17,6 +17,10 @@
"""
from zope.app.content.folder import Folder
from zopeproducts.NewsSite.interfaces import INewsSite
+from zopeproducts.NewsSite.NewsItem.interfaces import INewsItem
+from zope.publisher.browser import BrowserView
+from zope.app.interfaces.dublincore import ICMFDublinCore
+from zope.component import getAdapter
class NewsSite(Folder):
"""XXX to be written"""
@@ -24,3 +28,15 @@
__implements__ = (Folder.__implements__, INewsSite)
+class NewsSiteView(BrowserView):
+
+ __used_for__ = INewsSite
+
+ def listNewsItems(self):
+ site = [x for x in self.context.values()]
+ list = filter(lambda x: INewsItem.isImplementedBy(x), site)
+ list = [ (x, getAdapter(x, ICMFDublinCore).EffectiveDate()) for x in list ]
+ list.sort(lambda x,y: cmp(x[1], y[1]))
+ list = [ x[0] for x in list]
+ return list
+