예제 #1
0
    def testCopyBlobs(self):
        from zope.copy import copy
        file = NamedBlobFile()
        file.data = u'hello, world'
        image = NamedBlobImage()
        image.data = 'some image bytes'
        transaction.commit()

        file_copy = copy(file)
        self.assertEqual(file_copy.data, file.data)

        image_copy = copy(image)
        self.assertEqual(image_copy.data, image.data)
예제 #2
0
    def testCopyBlobs(self):
        from zope.copy import copy
        file = NamedBlobFile()
        file.data = u'hello, world'
        image = NamedBlobImage()
        image.data = 'some image bytes'
        transaction.commit()

        file_copy = copy(file)
        self.assertEqual(file_copy.data, file.data)

        image_copy = copy(image)
        self.assertEqual(image_copy.data, image.data)
예제 #3
0
    def test_copy(self):
        orig_wref = self.make_one()

        wref2 = copy.copy(orig_wref)

        assert_that(wref2, is_(WeakRef))
        self.assertIsNot(orig_wref, wref2)
예제 #4
0
def clone_action(wf, context):  # pylint: disable=invalid-name,unused-argument
    """Create new version"""
    result = copy(context)
    locate(result, context.__parent__)
    registry = get_pyramid_registry()
    registry.notify(ObjectClonedEvent(result, context))
    return result
예제 #5
0
파일: utils.py 프로젝트: ArcheProject/Arche
def copy_recursive(original_contex, change_uids = True):
    """ Note that a copy should always have changed UIDs if the original is kept
        in the resource tree.
    """
    new_context = copy(original_contex)
    for obj in find_all_db_objects(new_context):
        if change_uids and hasattr(obj, 'uid'):
            obj.uid = unicode(uuid4())
    return new_context
예제 #6
0
    def copy(self, name, other, newname=None, registry=None):
        """
        Copy a subobject named ``name`` from this folder to the folder
        represented by ``other``.  If ``newname`` is not none, it is used as
        the target object name; otherwise the existing subobject name is
        used.
        """
        if newname is None:
            newname = name

        if registry is None:
            registry = get_current_registry()

        with statsd_timer('folder.copy'):
            obj = self[name]
            newobj = copy(obj)
            return other.add(
                newname, newobj, duplicating=obj, registry=registry
                )
예제 #7
0
    def copy(self, name, other, newname=None, registry=None):
        """
        Copy a subobject named ``name`` from this folder to the folder
        represented by ``other``.  If ``newname`` is not none, it is used as
        the target object name; otherwise the existing subobject name is
        used.
        """
        if newname is None:
            newname = name

        if registry is None:
            registry = get_current_registry()

        with statsd_timer('folder.copy'):
            obj = self[name]
            newobj = copy(obj)
            return other.add(
                newname, newobj, duplicating=obj, registry=registry
                )
예제 #8
0
    def copyTo(self, target, new_name=None):
        """Copy this object to the `target` given.

        Returns the new name within the `target`. After the copy
        is created and before adding it to the target container,
        an `IObjectCopied` event is published.
        """
        obj = self.context

        orig_name = obj.__name__
        if new_name is None:
            new_name = orig_name

        checkObject(target, new_name, obj)

        chooser = INameChooser(target)
        new_name = chooser.chooseName(new_name, obj)

        new = copy(obj)
        notify(ObjectCopiedEvent(new, obj))

        target[new_name] = new
        return new_name
예제 #9
0
    def copyTo(self, target, new_name=None):
        """Copy this object to the `target` given.

        Returns the new name within the `target`. After the copy
        is created and before adding it to the target container,
        an `IObjectCopied` event is published.
        """
        obj = self.context
        container = obj.__parent__

        orig_name = obj.__name__
        if new_name is None:
            new_name = orig_name

        checkObject(target, new_name, obj)

        chooser = INameChooser(target)
        new_name = chooser.chooseName(new_name, obj)

        new = copy(obj)
        notify(ObjectCopiedEvent(new, obj))

        target[new_name] = new
        return new_name
예제 #10
0
 def create(self, data):
     return copy(self.context)
예제 #11
0
 def __init__(self, ob):
     super(CopyingWeakRef, self).__init__(ob)
     self._copy = copy.copy(ob)
예제 #12
0
 def _callFUT(self, obj):
     from zope.copy import copy
     return copy(obj)