[Zope3-checkins] CVS: Products3/NewsSite - newsindex.pt:1.2 newssite.py:1.3

Christian Theune ct@gocept.com
Wed, 26 Mar 2003 11:53:40 -0500


Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv6220

Modified Files:
	newsindex.pt newssite.py 
Log Message:
 - added context wrapping for absolute url
 - added convenience method for workflow awareness


=== Products3/NewsSite/newsindex.pt 1.1 => 1.2 ===
--- Products3/NewsSite/newsindex.pt:1.1	Wed Mar 26 09:45:57 2003
+++ Products3/NewsSite/newsindex.pt	Wed Mar 26 11:53:39 2003
@@ -4,7 +4,7 @@
 <div metal:fill-slot="body">
 
   <ul>
-    <li tal:repeat="item view/listNewsItems" tal:content="item/title"/>
+    <li tal:repeat="item view/listPublicNewsItems" tal:content="item/title"/>
   </ul>
 
 </div>


=== Products3/NewsSite/newssite.py 1.2 => 1.3 ===
--- Products3/NewsSite/newssite.py:1.2	Wed Mar 26 09:56:14 2003
+++ Products3/NewsSite/newssite.py	Wed Mar 26 11:53:39 2003
@@ -21,22 +21,28 @@
 from zope.publisher.browser import BrowserView 
 from zope.app.interfaces.dublincore import ICMFDublinCore
 from zope.component import getAdapter
+from zope.proxy.context import ContextWrapper
 
 class NewsSite(Folder):
-	"""XXX to be written"""
+    """XXX to be written"""
 
-	__implements__ = (Folder.__implements__, INewsSite)
+    __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
+    __used_for__ = INewsSite
+
+    def listPublicNewsItems(self):
+        return self._list()
+    
+    def _list(self):
+        site = [ ContextWrapper(self.context[x], self.context, name=x) 
+                 for x in self.context]
+        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