[Checkins] SVN: plone.z3cform/trunk/plone/z3cform/add.py Remove add.py from the repository. This is only confusing right now.

Daniel Nouri daniel.nouri at gmail.com
Wed Jul 30 08:02:49 EDT 2008


Log message for revision 89018:
  Remove add.py from the repository.  This is only confusing right now.
  Please resurrect once it's usable and tested.
  

Changed:
  D   plone.z3cform/trunk/plone/z3cform/add.py

-=-
Deleted: plone.z3cform/trunk/plone/z3cform/add.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/add.py	2008-07-30 11:58:23 UTC (rev 89017)
+++ plone.z3cform/trunk/plone/z3cform/add.py	2008-07-30 12:02:48 UTC (rev 89018)
@@ -1,74 +0,0 @@
-from zope.app.container.interfaces import IContainerNamesContainer
-from zope.app.container.interfaces import INameChooser
-from zope.app.container.constraints import checkObject
-
-from Acquisition import aq_inner, aq_base
-from AccessControl import Unauthorized
-
-from Products.CMFCore.utils import getToolByName
-
-from z3c.form import form
-
-class AddForm(form.AddForm):
-    """CMF implementation of the add form
-    """
-    
-    contentName = None
-    
-    def add(self, object):
-        
-        container = aq_inner(self.context)
-        content = object
-        
-        name = self.contentName
-        chooser = INameChooser(container)
-
-        # Ensure that construction is allowed
-
-        portal_types = getToolByName(container, 'portal_types')
-        fti = portal_types.getTypeInfo(content)
-
-        if fti is not None:
-            # Check add permission
-            if not fti.isConstructionAllowed(container):
-                raise Unauthorized(u"You are not allowed to create a %d here" % fti.getId())
-            # Check allowable content types
-            if  getattr(aq_base(container), 'allowedContentTypes', None) is not None and \
-                    not fti.getId() in container.allowedContentTypes():
-                raise Unauthorized(u"You are not allowed to create a %d here" % fti.getId())
-
-        # check preconditions
-        checkObject(container, name, content)
-
-        if IContainerNamesContainer.providedBy(container):
-            # The container picks it's own names.
-            # We need to ask it to pick one.
-            name = chooser.chooseName(self.contentName or '', content)
-        else:
-            request = self.request
-            name = request.get('add_input_name', name)
-
-            if name is None:
-                name = chooser.chooseName(self.contentName or '', content)
-            elif name == '':
-                name = chooser.chooseName('', content)
-            else:
-                # Invoke the name chooser even when we have a
-                # name. It'll do useful things with it like converting
-                # the incoming unicode to an ASCII string.
-                name = chooser.chooseName(name, container)
-        
-        if not name:
-            raise ValueError("Cannot add content: name chooser did not provide a name")
-        
-        content.id = name
-        container._setObject(name, content)
-        content = container._getOb(name)
-        
-        if fti is not None:
-            fti._finishConstruction(content)
-            
-        self.contentName = name
-
-    def nextURL(self):
-        return "%s/%s/view" % (self.context.absolute_url(), self.contentName)
\ No newline at end of file



More information about the Checkins mailing list