Esempio n. 1
0
 def test_copyable(self):
     root = self.rootFolder
     container = traverse(root, 'folder1')
     container['file1'] = File()
     file = traverse(root, 'folder1/file1')
     copier = IObjectCopier(file)
     self.failUnless(copier.copyable())
Esempio n. 2
0
 def test_copyable(self):
     root = self.rootFolder
     container = traverse(root, 'folder1')
     container['file1'] = File()
     file = traverse(root, 'folder1/file1')
     copier = IObjectCopier(file)
     self.failUnless(copier.copyable())
Esempio n. 3
0
    def handleCopy(self, action):
        if not len(self.selectedItems):
            self.status = self.copyNoItemsMessage
            return

        items = []
        append = items.append
        for obj in self.selectedItems:
            __name__ = api.getName(obj)
            copier = IObjectCopier(obj)
            if not copier.copyable():
                m = {"name": __name__}
                if __name__:
                    m["name"] = __name__
                    self.status = _(
                        "Object '${name}' (${name}) cannot be copied",
                        mapping=m)
                else:
                    self.status = _("Object '${name}' cannot be copied",
                                   mapping=m)
                transaction.doom()
                return
            append(api.joinPath(api.getPath(self.context), __name__))

        self.status = self.copyItemsSelected
        # store the requested operation in the principal annotations:
        self.clipboard.clearContents()
        self.clipboard.addItems('copy', items)
Esempio n. 4
0
    def copyObjects(self):
        """Copy objects specified in a list of object ids"""
        request = self.request
        ids = request.get('ids')

        if not ids:
            IStatusMessage(request).add(
                _("You didn't specify any ids to copy."), 'error')
            return

        container = self.context
        container_path = getPath(container)

        items = []
        for id in ids:
            ob = container[id]
            copier = IObjectCopier(ob)
            if not copier.copyable():
                IStatusMessage(request).add(
                    _("Object '${name}' cannot be copied", {"name": id}),
                    'error'
                )
                return
            items.append(joinPath(container_path, id))

        # store the requested operation in the principal annotations:
        clipboard = getPrincipalClipboard(request)
        clipboard.clearContents()
        clipboard.addItems('copy', items)

        IStatusMessage(request).add(_('Selected items has been copied.'))
Esempio n. 5
0
    def __bind__(self, content, globalenviron, environ):
        clone = super(IdColumn, self).__bind__(content, globalenviron, environ)

        table = self.table

        copier = IObjectCopier(content, None)
        if copier is not None and copier.copyable() and \
            canAccess(table.context, '__setitem__') and \
            not IUncopyableContent.providedBy(content):
            copyable = True
            table.supportsCopy = True
        else:
            copyable = False

        moveable = False
        renameable = False
        deletable = False

        if not IUnremoveableContent.providedBy(content):
            mover = IObjectMover(content, None)
            if mover is not None and mover.moveable():
                if not IUnpastableContent.providedBy(content):
                    moveable = True
                    table.supportsCut = True
                if not IRenameNotAllowed.providedBy(content):
                    renameable = \
                        not IContainerNamesContainer.providedBy(self.context)

                    if renameable:
                        table.supportsRename = True

        if not IUnremoveableContent.providedBy(content) and \
                checkPermission('zojax.DeleteContent', content):
            deletable = True
            table.supportsDelete = True

        clone.buttons = copyable or moveable or renameable or deletable

        return clone
    def copyObjects(self):
        """Copy objects specified in a list of object ids"""
        request = self.request
        ids = request.get('ids')

        if not ids:
            self.error = _("You didn't specify any ids to copy.")
            return

        container_path = getPath(self.context)

        # For each item, check that it can be copied; if so, save the
        # path of the object for later copying when a destination has
        # been selected; if not copyable, provide an error message
        # explaining that the object can't be copied.
        items = []
        for id in ids:
            ob = self.context[id]
            copier = IObjectCopier(ob)
            if not copier.copyable():
                m = {"name": id}
                title = getDCTitle(ob)
                if title:
                    m["title"] = title
                    self.error = _(
                        "Object '${name}' (${title}) cannot be copied",
                        mapping=m)
                else:
                    self.error = _("Object '${name}' cannot be copied",
                                   mapping=m)
                return
            items.append(joinPath(container_path, id))

        # store the requested operation in the principal annotations:
        clipboard = getPrincipalClipboard(self.request)
        clipboard.clearContents()
        clipboard.addItems('copy', items)
Esempio n. 7
0
    def copyObjects(self):
        """Copy objects specified in a list of object ids"""
        request = self.request
        ids = request.get('ids')
        if not ids:
            self.error = _("You didn't specify any ids to copy.")
            return

        container_path = getPath(self.context)

        # For each item, check that it can be copied; if so, save the
        # path of the object for later copying when a destination has
        # been selected; if not copyable, provide an error message
        # explaining that the object can't be copied.
        items = []
        for id in ids:
            ob = self.context[id]
            copier = IObjectCopier(ob)
            if not copier.copyable():
                m = {"name": id}
                title = getDCTitle(ob)
                if title:
                    m["title"] = title
                    self.error = _(
                        "Object '${name}' (${title}) cannot be copied",
                        mapping=m)
                else:
                    self.error = _("Object '${name}' cannot be copied",
                                   mapping=m)
                return
            items.append(joinPath(container_path, id))

        # store the requested operation in the principal annotations:
        clipboard = getPrincipalClipboard(self.request)
        clipboard.clearContents()
        clipboard.addItems('copy', items)