[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container - adding.py:1.19.2.3 contents.py:1.25.8.2

Jim Fulton jim at zope.com
Fri Sep 12 15:16:08 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv13470/src/zope/app/browser/container

Modified Files:
      Tag: parentgeddon-branch
	adding.py contents.py 
Log Message:
Can't have the tests passing, can we?

=== Zope3/src/zope/app/browser/container/adding.py 1.19.2.2 => 1.19.2.3 ===
--- Zope3/src/zope/app/browser/container/adding.py:1.19.2.2	Tue Sep  9 16:31:56 2003
+++ Zope3/src/zope/app/browser/container/adding.py	Fri Sep 12 15:15:06 2003
@@ -26,7 +26,7 @@
 
 from zope.app.interfaces.container import IAdding
 from zope.app.interfaces.container import IContainerNamesContainer
-from zope.app.interfaces.container import IAddTarget
+from zope.app.interfaces.container import INameChooser
 
 from zope.app.event.objectevent import ObjectCreatedEvent
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -37,6 +37,9 @@
 from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.interface import implements
 
+from zope.app.location import LocationProxy
+import zope.security.checker
+
 class BasicAdding(BrowserView):
 
     implements(IAdding, IPublishTraverse)
@@ -45,9 +48,20 @@
 
     def add(self, content):
         """See zope.app.interfaces.container.IAdding"""
-        container = zapi.getAdapter(self.context, IAddTarget)
-        name = container.addObject(self.contentName, content)
-        return self.context[name]
+
+        container = self.context
+        name = self.contentName
+        
+        chooser = zapi.getAdapter(container, INameChooser)
+        if IContainerNamesContainer.isImplementedBy(container):
+            # The container pick's it's own names.
+            # We need to ask it to pick one.
+            name = chooser.chooseName(self.contentName or '', content)
+        else:
+            chooser.checkName(name, container)
+
+        container[name] = content
+        return container[name]
 
     contentName = None # usually set by Adding traverser
 
@@ -109,7 +123,10 @@
                 raise UserError(_(u"You must specify an id"))
             self.contentName = id
 
-        content = zapi.createObject(self, type_name)
+        factory = zapi.getFactory(self, type_name)
+        factory = LocationProxy(factory, self, type_name)
+        factory = zope.security.checker.ProxyFactory(factory)
+        content = factory()
         publish(self.context, ObjectCreatedEvent(content))
 
         self.add(content)


=== Zope3/src/zope/app/browser/container/contents.py 1.25.8.1 => 1.25.8.2 ===
--- Zope3/src/zope/app/browser/container/contents.py:1.25.8.1	Mon Sep  8 14:21:23 2003
+++ Zope3/src/zope/app/browser/container/contents.py	Fri Sep 12 15:15:06 2003
@@ -17,7 +17,7 @@
 """
 
 from zope.app import zapi
-from zope.app.interfaces.container import IContainer, IRemoveSource
+from zope.app.interfaces.container import IContainer
 from zope.app.interfaces.dublincore import IZopeDublinCore
 from zope.app.interfaces.size import ISized
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
@@ -25,8 +25,6 @@
 from zope.app.interfaces.copypastemove import IPrincipalClipboard
 from zope.app.interfaces.copypastemove import IObjectCopier
 from zope.app.interfaces.copypastemove import IObjectMover
-from zope.app.interfaces.container import IPasteTarget
-from zope.app.interfaces.container import ICopySource, IMoveSource
 from zope.app.interfaces.dublincore import IDCDescriptiveProperties
 from zope.app.i18n import ZopeMessageIDFactory as _
 from zope.app.browser.container.adding import BasicAdding
@@ -98,13 +96,9 @@
 
         info = map(self._extractContentInfo, self.context.items())
 
-        self.supportsCut = (
-            info and zapi.queryAdapter(self.context, IMoveSource) is not None)
-        self.supportsCopy = (
-            info and zapi.queryAdapter(self.context, ICopySource) is not None)
-        self.supportsPaste = (
-            zapi.queryAdapter(self.context, IPasteTarget) is not None)
-
+        self.supportsCut = info
+        self.supportsCopy = info
+        self.supportsPaste = True
         self.supportsRename = self.supportsCut and self.supportsPaste
 
         return info
@@ -213,9 +207,9 @@
             self.error = _("You didn't specify any ids to remove.")
             return
 
-        container = zapi.getAdapter(self.context, IRemoveSource)
+        container = self.context
         for id in ids:
-            container.removeObject(id)
+            del container[id]
 
     def copyObjects(self):
         """Copy objects specified in a list of object ids"""




More information about the Zope3-Checkins mailing list