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())
def handleCut(self, action): if not len(self.selectedItems): self.status = self.cutNoItemsMessage return items = [] append = items.append for obj in self.selectedItems: mover = IObjectMover(obj) __name__ = api.getName(obj) if not mover.moveable(): m = {"name": __name__} if name: m["name"] = __name__ self.status = _( "Object '${name}' (${name}) cannot be moved", mapping=m) else: self.status = _("Object '${name}' cannot be moved", mapping=m) transaction.doom() return append(api.joinPath(api.getPath(self.context), __name__)) self.status = self.cutItemsSelected # store the requested operation in the principal annotations: self.clipboard.clearContents() self.clipboard.addItems('cut', items)
def cutObjects(self): """move 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 cut."), 'error') return container = self.context container_path = getPath(container) items = [] for id in ids: ob = container[id] mover = IObjectMover(ob) if not mover.moveable(): IStatusMessage(request).add( _("Object '${name}' cannot be moved", {"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('cut', items) IStatusMessage(request).add(_('Selected items has been cut.'))
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 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 = 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(joinPath(container_path, id)) # store the requested operation in the principal annotations: clipboard = getPrincipalClipboard(self.request) clipboard.clearContents() clipboard.addItems('cut', items)