Ejemplo n.º 1
0
    def allowRename(self):
        if IRenameNotAllowed.providedBy(self.context):
            return False

        container = self.context.__parent__
        return (IWriteContainer.providedBy(container) and
                not IContainerNamesContainer.providedBy(container) and
                canAccess(container, '__setitem__'))
Ejemplo n.º 2
0
    def nameAllowed(self):
        """Return whether names can be input by the user."""
        context = self.context

        if IContentType.providedBy(context):
            context = context.context

        if IAdding.providedBy(context):
            context = context.context

        if IWriteContainer.providedBy(context):
            return not IContainerNamesContainer.providedBy(context)
        else:
            return False
Ejemplo n.º 3
0
def checkContentType(container, contenttype):
    if not (IWriteContainer.providedBy(container) or IContentContainer.providedBy(container)):
        raise TypeError("Container is not a valid Zope container.")

    ct = IContentType(container, None)
    if ct is None:
        raise InvalidContainerType(container)

    # check item precondition
    precondition = ctContains(ct)
    if precondition is not None:
        precondition(container, "", contenttype)

    # check the container constraint
    validate = queryUtility(IContainerTypesConstraint, contenttype.name)
    if validate is not None:
        validate(container)
Ejemplo n.º 4
0
def checkObject(container, name, object):
    """Check containement constraints for an object and container"""
    if not (IWriteContainer.providedBy(container) or IContentContainer.providedBy(container)):
        raise TypeError("Container is not a valid Zope container.")

    # check item precondition
    precondition = contains(container)
    if precondition is not None:
        precondition(container, name, object)
    else:
        contenttype = IContentType(object, None)
        if contenttype is None:
            raise InvalidItemType(container, object, ())

    # check the container constraint
    validate = containers(object)
    if validate is not None:
        validate(container)
Ejemplo n.º 5
0
    def fields(self):
        if self.step.name != 'content' or \
                not isinstance(self.step, ContentStep):
            return Fields()

        context = self.context

        if not ISite.providedBy(context):
            if IRenameNotAllowed.providedBy(context):
                return Fields()

            if not IContentNamesContainer.providedBy(context):
                location = context.__parent__
                if IWriteContainer.providedBy(location) and \
                        not IContainerNamesContainer.providedBy(location):
                    return Fields(IContentRenameForm)

        return Fields()