Ejemplo n.º 1
0
 def test_moveable(self):
     root = self.rootFolder
     container = traverse(root, 'folder1')
     container['file1'] = File()
     file = traverse(root, 'folder1/file1')
     mover = IObjectMover(file)
     self.failUnless(mover.moveable())
Ejemplo n.º 2
0
    def cutObjects(self):
        """move 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 cut.")
            return

        container_path = zapi.getPath(self.context)

        # For each item, check that it can be moved; if so, save the
        # path of the object for later moving when a destination has
        # been selected; if not movable, provide an error message
        # explaining that the object can't be moved.
        items = []
        for id in ids:
            ob = self.context[id]
            mover = IObjectMover(ob)
            if not mover.moveable():
                m = {"name": id}
                title = getDCTitle(ob)
                if title:
                    m["title"] = title
                    self.error = _(
                        "Object '${name}' (${title}) cannot be moved",
                        mapping=m)
                else:
                    self.error = _("Object '${name}' cannot be moved",
                                   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('cut', items)