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)
def test_copy(self): orig_wref = self.make_one() wref2 = copy.copy(orig_wref) assert_that(wref2, is_(WeakRef)) self.assertIsNot(orig_wref, wref2)
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
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
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 )
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
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
def create(self, data): return copy(self.context)
def __init__(self, ob): super(CopyingWeakRef, self).__init__(ob) self._copy = copy.copy(ob)
def _callFUT(self, obj): from zope.copy import copy return copy(obj)