Wichert Akkerman wrote:
PortalFolderBase overrides _verifyObjectPaste to add some extra checks
on top of OFS's CopyContainer to check if content may be pasted: it
copies the permission checking (why doesn't it call the base class for

It does call the base class *if* support for the deprecated multi-factories is not required.

and adds code to check for allowed types. There is one check
missing there that is checked when creating new object: the FTI may
block creation of new content as well through
its isConstructionAllowed method. Is there any reason
_verifyObjectPaste check this as well? This should be simple to do:

    portal_type = getattr(aq_base(obj), 'portal_type', None)
    if portal_type:
        fti = queryUtility(ITypeInformation, name=portal_type)
        if fti is not None and not fti.isConstructionAllowed(self):
            raise ValueError('You can not add the copied content here.')

The change is actually much simpler: replace the current workflow guard
check with a call to objType.isConstructionAllowed(self). The FTI checks
for workflow guards already so you won't need to duplicate that code
anymore either.

isConstructionAllowed just returns a boolean value, _verifyObjectPaste tells you what went wrong. Maybe there should be a new method that raises errors and can be used by isConstructionAllowed and _verifyObjectPaste?



Zope-CMF maillist  -  Zope-CMF@zope.org

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Reply via email to