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)
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()
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()
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)
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)
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)
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 )