コード例 #1
0
    def copy_content(self, objs=[]):
        """
        make a copy of the object and add it to current container
        if id already exists, create a copy-of id
        """
        copied = []

        objs = objs or self.request.params.get('objs', "").split("::")
        for path in objs:
            obj = path_to_object(path, self.context.root, path_sep=".")
            if obj is not None:
                cpy = copy.deepcopy(obj)
                # create new content id if it already exists
                cpy.set_id(self.context.generate_content_id(obj.id))
                self.context.add_content(cpy)
                self.request.registry.notify(ContentAdded(cpy, self.context))
                copied.append(cpy.id)

        return copied
コード例 #2
0
    def move_content(self, objs=[]):

        """ Should receive a list of dotted paths """

        objs = objs or self.request.params.get('objs', "").split("::")

        moved = []

        for path in objs:

            obj = path_to_object(path, self.context.root, path_sep=".")

            if obj is not None:
                content = obj.__parent__.remove_content(obj.id)
                self.context.add_content(content)
                self.request.registry.notify(
                    ContentChanged(content, self.request))
                moved.append(obj.id)

        return moved
コード例 #3
0
    def get_object(self, docid):

        metadata = self._document_map.get_metadata(docid)
        path = metadata['path']
        return path_to_object(path, self.__parent__)
コード例 #4
0
    def test_path_to_object(self):

        assert self.x0 == path_to_object("/f0/x0", self.root)