[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Adding.py:1.7.2.1 Contents.py:1.7.2.1

Jim Fulton jim@zope.com
Thu, 3 Oct 2002 18:17:21 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv27190/lib/python/Zope/App/OFS/Container/Views/Browser

Modified Files:
      Tag: ZopeDublinCore-branch
	Adding.py Contents.py 
Log Message:
Checking in still-unfinished dublin core work on
ZopeDublinCore-branch.

To do:

  - Make a number of existing tests work now that a lot of views 
    need to generate events. (Perhaps these will need to 
    be factored into adapters and views. Sigh.)

  - Make object events able to compute locations for there
    objects when an location hasn't been provided to the constructor.

  - Add some UI for editing at least some meta data.

Handling of lists (e.g. subjects, creators) may need some more thought
as these will often want to come from standard system-provided lists.




=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py 1.7 => 1.7.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py:1.7	Wed Oct  2 17:35:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py	Thu Oct  3 18:16:50 2002
@@ -25,6 +25,9 @@
 from Zope.App.PageTemplate import ViewPageTemplateFile
 from Zope.ContextWrapper import ContextMethod, getbaseobject
 from Zope.Proxy.ContextWrapper import ContextWrapper
+from Zope.Event import publishEvent
+from Zope.Event.ObjectEvent \
+     import ObjectCreatedEvent, ObjectModifiedEvent, ObjectAddedEvent
 
 class Adding(BrowserView):
 
@@ -40,7 +43,10 @@
         'See Zope.App.OFS.Container.IAdding.IAdding'
         content = removeAllProxies(content) # XXX We need to think about this
         name = self.context.setObject(self.contentName, content)
-        return ContextWrapper(self.context[name], self.context, name=name)
+        content = ContextWrapper(self.context[name], self.context, name=name)
+        publishEvent(self.context, ObjectAddedEvent(content))
+        publishEvent(self.context, ObjectModifiedEvent(self.context))
+        return content
     
     # See Zope.App.OFS.Container.Views.Browser.IAdding.IAdding
     contentName=None # usually set by Adding traverser
@@ -109,6 +115,8 @@
         self.contentName = id
         
         content = createObject(self, type_name)
+        publishEvent(self.context, ObjectCreatedEvent(content))
+        
         self.add(content)
         self.request.response.redirect(self.nextURL())
 


=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py 1.7 => 1.7.2.1 ===
--- 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	Thu Oct  3 18:16:50 2002
@@ -18,25 +18,42 @@
 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'] = created
 
         return info
 
@@ -46,6 +63,8 @@
         for id in ids:
             self.remove(id)
 
+        publishEvent(self.context, ObjectModifiedEvent(self.context))
+
         if REQUEST is not None:
             # for unit tests
             REQUEST.response.redirect(
@@ -62,7 +81,10 @@
             exception).
         """
         try:
+            content = ContextWrapper(self.context[name], self.context,
+                                     name=name)
             del self.context[name]
+            publishEvent(self.context, ObjectRemovedEvent(content))
         except KeyError:
             if not silent:
                 raise