[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Adding.py:1.8.4.1 Contents.py:1.8.4.1
Suresh Babu Eddala
sbabu@zeomega.com
Mon, 21 Oct 2002 11:59:16 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv11840/lib/python/Zope/App/OFS/Container/Views/Browser
Modified Files:
Tag: Zope3-Bangalore-TTW-Branch
Adding.py Contents.py
Log Message:
Managing(SetObject, delitem, ...) the object in context of the container.
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py 1.8 => 1.8.4.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py:1.8 Fri Oct 4 15:48:30 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adding.py Mon Oct 21 11:58:45 2002
@@ -17,18 +17,18 @@
"""
from Zope.App.OFS.Container.IAdding import IAdding
-from Zope.Proxy.ProxyIntrospection import removeAllProxies
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.Publisher.IPublishTraverse import IPublishTraverse
from Zope.ComponentArchitecture \
- import getView, getService, createObject, queryFactory, queryView
+ import getView, getService, createObject, \
+ queryFactory, queryView, getAdapter
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
-
+from Zope.App.OFS.Container.IZopeContainer import IZopeContainer
class Adding(BrowserView):
__implements__ = IAdding, IPublishTraverse
@@ -41,12 +41,11 @@
def add(self, content):
'See Zope.App.OFS.Container.IAdding.IAdding'
- content = removeAllProxies(content) # XXX We need to think about this
- name = self.context.setObject(self.contentName, content)
- content = ContextWrapper(self.context[name], self.context, name=name)
- publishEvent(self.context, ObjectAddedEvent(content))
- publishEvent(self.context, ObjectModifiedEvent(self.context))
- return content
+ container = self.context
+ container = getAdapter(container, IZopeContainer)
+ name = container.setObject(self.contentName, content)
+ return container[name]
+
# See Zope.App.OFS.Container.Views.Browser.IAdding.IAdding
contentName=None # usually set by Adding traverser
=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py 1.8 => 1.8.4.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py:1.8 Fri Oct 4 15:55:17 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Contents.py Mon Oct 21 11:58:45 2002
@@ -18,11 +18,12 @@
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, queryAdapter
+from Zope.ComponentArchitecture import queryView, getView, queryAdapter,\
+ getAdapter
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
+from Zope.App.OFS.Container.IZopeContainer import IZopeContainer
class Contents(BrowserView):
@@ -60,24 +61,13 @@
def removeObjects(self, ids):
"""Remove objects specified in a list of object ids"""
+ container = self.context
for id in ids:
- self._remove(id)
-
- publishEvent(self.context, ObjectModifiedEvent(self.context))
+ container = getAdapter(container, IZopeContainer)
+ container.__delitem__(id)
self.request.response.redirect('@@contents.html')
-
- def _remove(self, name):
- """
- Remove the object stored under 'name', or raise a KeyError
- if no such object.
- """
- 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())