[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Contents.py:1.8
Jim Fulton
jim@zope.com
Fri, 4 Oct 2002 15:55:18 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv5694/lib/python/Zope/App/OFS/Container/Views/Browser
Modified Files:
Contents.py
Log Message:
Added dublin core data to folder info.
Added logic to generate object events when objects are removed.
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py:1.7 Tue Oct 1 08:49:07 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py Fri Oct 4 15:55:17 2002
@@ -18,61 +18,71 @@
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.PageTemplate import ViewPageTemplateFile
from Zope.App.OFS.Container.IContainer import IContainer
-from Zope.ComponentArchitecture import queryView, getView
+from Zope.ComponentArchitecture import queryView, getView, queryAdapter
+from Zope.App.DublinCore.IZopeDublinCore import IZopeDublinCore
+from Zope.Event import publishEvent
+from Zope.Event.ObjectEvent import ObjectModifiedEvent, ObjectRemovedEvent
+from Zope.Proxy.ContextWrapper import ContextWrapper
class Contents(BrowserView):
__used_for__ = IContainer
def _extractContentInfo( self, item ):
- info = {}
+ info = { }
info['id'] = item[0]
info['object'] = item[1]
- info[ 'title' ] = info[ 'url' ] = item[0]
+ info[ 'url' ] = item[0]
zmi_icon = queryView(item[1], 'zmi_icon', self.request)
if zmi_icon is None:
info['icon'] = None
else:
info['icon'] = zmi_icon()
-
+
+ dc = queryAdapter(item[1], IZopeDublinCore)
+ if dc is not None:
+ title = dc.title
+ if title:
+ info['title'] = title
+
+ created = dc.created
+ if created is not None:
+ info['created'] = created
+
+ modified = dc.modified
+ if modified is not None:
+ info['modified'] = modified
return info
- def removeObjects(self, ids, REQUEST=None):
- """ """
+ def removeObjects(self, ids):
+ """Remove objects specified in a list of object ids"""
for id in ids:
- self.remove(id)
+ self._remove(id)
+
+ publishEvent(self.context, ObjectModifiedEvent(self.context))
- if REQUEST is not None:
- # for unit tests
- REQUEST.response.redirect(
- getView(self.context, "absolute_url", REQUEST)
- )
- return
- return self.confirmRemoved()
-
+ self.request.response.redirect('@@contents.html')
+
- def remove( self, name, silent=0 ):
+ def _remove(self, name):
"""
Remove the object stored under 'name', or raise a KeyError
- if no such object (pass non-zero 'silent' to suppress the
- exception).
+ if no such object.
"""
- try:
- del self.context[name]
- except KeyError:
- if not silent:
- raise
- return self.confirmRemoved( name=name )
+ content = ContextWrapper(self.context[name], self.context,
+ name=name)
+ del self.context[name]
+ publishEvent(self.context, ObjectRemovedEvent(content))
def listContentInfo(self):
return map(self._extractContentInfo, self.context.items())
contents = ViewPageTemplateFile('main.pt')
- confirmRemoved = ViewPageTemplateFile('remove_confirmed.pt')
+ contentsMacros = contents
_index = ViewPageTemplateFile('index.pt')