def resolve(self, path): try: self.edited_item = Item.require_instance(int(path.pop(0))) except: raise cherrypy.HTTPError(400) return self
def invoke(self, controller, selection): clipboard = get_block_clipboard_contents() if not clipboard: notify_user( translations("woost.block_clipboard.empty"), "error" ) else: try: block = Block.require_instance(clipboard["block"]) src_parent = Item.require_instance(clipboard["block_parent"]) src_slot = type(src_parent).get_member(clipboard["block_slot"]) except: notify_user( translations("woost.block_clipboard.error"), "error" ) else: # Remove the block from the source location if clipboard["mode"] == "cut": if isinstance(src_slot, schema.Reference): src_parent.set(src_slot, None) elif isinstance(src_slot, schema.Collection): src_collection = src_parent.get(src_slot) schema.remove(src_collection, block) # Or copy it elif clipboard["mode"] == "copy": block = block.create_copy() block.insert() # Add the block to its new position add_block( block, controller.block_parent, controller.block_slot, positioning = self.block_positioning, anchor = controller.block ) datastore.commit() del session[BLOCK_CLIPBOARD_SESSION_KEY] focus_block(block)
def __setstate__(self, state): self._stack = state["_stack"] self._parent_node = state["_parent_node"] self._index = state["_index"] self.item = Item.require_instance(state["item"])