[Zope3-checkins] CVS: Products3/NewsSite - newssite.py:1.9
Tres Seaver
tseaver@zope.com
Tue, 1 Apr 2003 10:50:32 -0500
Update of /cvs-repository/Products3/NewsSite
In directory cvs.zope.org:/tmp/cvs-serv3721
Modified Files:
newssite.py
Log Message:
- Reorder imports.
- Use new "force auth" base class for view.
- Include DublinCore adapter for items in info.
=== Products3/NewsSite/newssite.py 1.8 => 1.9 ===
--- Products3/NewsSite/newssite.py:1.8 Thu Mar 27 12:42:42 2003
+++ Products3/NewsSite/newssite.py Tue Apr 1 10:50:31 2003
@@ -15,26 +15,26 @@
$Id$
"""
-from zope.app.datetimeutils import parseDatetimetz
from persistence.dict import PersistentDict
-from zope.component import getService
from zope.component import getAdapter, getView
+from zope.proxy.context import ContextWrapper
from zope.security.management import getSecurityManager
from zope.exceptions.unauthorized import Unauthorized
from zope.publisher.browser import BrowserView
+
from zope.app.interfaces.annotation import IAnnotations
from zope.app.interfaces.dublincore import ICMFDublinCore
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.services.servicenames import Authentication
-from zope.app.content.folder import Folder
from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
from zope.app.browser.workflow.stateful.interfaces import IContentFilterAdapter
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+from zope.app.content.folder import Folder
+from zope.app.datetimeutils import parseDatetimetz
from interfaces import INewsSite
from interfaces import ISyndicationPolicies
from NewsItem.interfaces import INewsItem
-from zope.proxy.context import ContextWrapper
+from browser import BaseNewsSiteView
class NewsSite(Folder):
"""XXX to be written"""
@@ -42,10 +42,11 @@
__implements__ = (Folder.__implements__, INewsSite)
-class NewsSiteView(BrowserView):
+class NewsSiteView(BrowserView, BaseNewsSiteView):
__used_for__ = INewsSite
- __implements__ = (BrowserView.__implements__, IProcessInstanceContainerAdaptable)
+ __implements__ = (BrowserView.__implements__,
+ IProcessInstanceContainerAdaptable)
def listPublicNewsItems(self):
return self._list(state=u"published")
@@ -56,17 +57,6 @@
def listPrivateNewsItems(self):
return self._list(state=u"private")
- def unauth(self):
- authsvc = getService(self.context, Authentication)
- principal = getSecurityManager().getPrincipal()
- if principal.getRoles():
- self.request.response.redirect( getView( self.context
- , 'absolute_url'
- , self.request
- ) )
- else:
- authsvc.unauthorized(None, self.request)
-
def _list(self, state=u"published"):
"""Return a sequence of mappings for our news items.
@@ -97,19 +87,20 @@
list = filterAdapter.filterListByState(list, state)
for item in list:
- dc = getAdapter(item, ICMFDublinCore)
- date = dc.effective or dc.created
- info = {'obj' : item,
- 'dc' : dc,
- 'date' : self._dateString(date),
- 'effective' : self._dateString(dc.effective),
- 'expires' : self._dateString(dc.expires),
- 'absolute_url' :
- getView(item, 'absolute_url', self.request)(),
- 'review_url' :
- getView(item, 'absolute_url', self.request)()+u'/workflows.html'
- }
- decorated.append( (date, info) )
+ dc = getAdapter(item, ICMFDublinCore)
+ date = dc.effective or dc.created
+ info = {'obj' : item,
+ 'dc' : dc,
+ 'date' : self._dateString(date),
+ 'effective' : self._dateString(dc.effective),
+ 'expires' : self._dateString(dc.expires),
+ 'absolute_url' : getView(item, 'absolute_url',
+ self.request)(),
+ 'review_url' :
+ getView(item, 'absolute_url', self.request
+ )()+u'/workflows.html'
+ }
+ decorated.append( (date, info) )
decorated.sort()
decorated.reverse()