Ejemplo n.º 1
0
def _verifyObjectPaste(self, obj, validate_src=True):
    self._old__verifyObjectPaste(obj, validate_src=True)
    portal_type = getattr(aq_base(obj), "portal_type", None)
    constrains = IConstrainTypes(self, None)
    if constrains:
        allowed_ids = [i.getId() for i in constrains.allowedContentTypes()]
        if portal_type not in allowed_ids:
            raise ValueError("Disallowed subobject type: %s" % portal_type)
Ejemplo n.º 2
0
    def allowedContentTypes(self, context=None):
        if not context:
            context = self

        constrains = IConstrainTypes(context, None)
        if not constrains:
            return super(Container, self).allowedContentTypes()

        return constrains.allowedContentTypes()
Ejemplo n.º 3
0
    def allowedContentTypes(self, context=None):
        if not context:
            context = self

        constrains = IConstrainTypes(context, None)
        if not constrains:
            return super(Container, self).allowedContentTypes()

        return constrains.allowedContentTypes()
Ejemplo n.º 4
0
    def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
        """Invokes the portal_types tool
        """
        constrains = IConstrainTypes(self, None)

        if constrains and not type_name in [fti.getId() for fti in constrains.allowedContentTypes()]:
            raise ValueError('Subobject type disallowed by IConstrainTypes adapter: %s' % type_name)

        return super(Container, self).invokeFactory(type_name, id, RESPONSE, *args, **kw)
Ejemplo n.º 5
0
    def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
        """Invokes the portal_types tool
        """
        constrains = IConstrainTypes(self, None)

        if constrains and not type_name in [fti.getId() for fti in constrains.allowedContentTypes()]:
            raise ValueError('Subobject type disallowed by IConstrainTypes adapter: %s' % type_name)

        return super(Container, self).invokeFactory(type_name, id, RESPONSE, *args, **kw)
Ejemplo n.º 6
0
    def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
        # Invokes the portal_types tool.
        constrains = IConstrainTypes(self, None)

        if constrains:
            # Do permission check before constrain checking so we'll get
            # an Unauthorized over a ValueError.
            fti = queryUtility(ITypeInformation, name=type_name)
            if fti is not None and not fti.isConstructionAllowed(self):
                raise Unauthorized('Cannot create %s' % fti.getId())

            allowed_ids = [i.getId() for i in constrains.allowedContentTypes()]
            if type_name not in allowed_ids:
                raise ValueError(
                    'Subobject type disallowed by IConstrainTypes adapter: %s'
                    % type_name)

        return super(Container, self).invokeFactory(type_name, id, RESPONSE,
                                                    *args, **kw)
Ejemplo n.º 7
0
    def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
        # Invokes the portal_types tool.
        constrains = IConstrainTypes(self, None)

        if constrains:
            # Do permission check before constrain checking so we'll get
            # an Unauthorized over a ValueError.
            fti = queryUtility(ITypeInformation, name=type_name)
            if fti is not None and not fti.isConstructionAllowed(self):
                raise Unauthorized('Cannot create %s' % fti.getId())

            allowed_ids = [i.getId() for i in constrains.allowedContentTypes()]
            if type_name not in allowed_ids:
                raise ValueError(
                    'Subobject type disallowed by IConstrainTypes adapter: %s'
                    % type_name
                )

        return super(Container, self).invokeFactory(
            type_name, id, RESPONSE, *args, **kw
        )