[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container/Views/Browser - Adder.py:1.1.2.6

Jim Fulton jim@zope.com
Sun, 28 Apr 2002 13:17:07 -0400


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

Modified Files:
      Tag: Zope-3x-branch
	Adder.py 
Log Message:
HOTYB: Merged SecurityProxy-branch into main branch.  

All tests pass and folders can be listed and added through the web.
It is likely that most other things don't work and will need to be
fixed. The reason is that many accesses that should have been checked
before are now being checked and additional checks and thinking about
permissions and security settings are needed.

I'm in the process of drafting a paper for the wiki that describes the
changes in more detail.


=== Zope3/lib/python/Zope/App/OFS/Container/Views/Browser/Adder.py 1.1.2.5 => 1.1.2.6 ===
 from Zope.ComponentArchitecture.ContextDependent import ContextDependent
 from Zope.App.OFS.Container.Exceptions import DuplicateIDError
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
 
 class ContainerAdder(AttributePublisher, ContextDependent):
 
@@ -47,7 +48,14 @@
         if id in context.objectIds():
             raise DuplicateIDError, "ID '%s' already in use." % id
 
-        context.setObject(id, createObject(context, type_name))
+        # Create the new object
+        new_object = createObject(context, type_name)
+
+        # Remove thye security proxy and context wrappers, if any.
+        # It's a good thing this is trusted code. :)
+        new_object = removeAllProxies(new_object)
+
+        context.setObject(id, new_object)
 
         if REQUEST is not None:
             # for unit tests