示例#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())
示例#2
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 = zapi.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(zapi.joinPath(container_path, id))

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