From 1430fdc24f597828bd823193dc840a3d7874e0c2 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Mon, 27 Aug 2007 17:44:49 +0000 Subject: Add a copy method to the datastore wrapper. --- (limited to 'sugar/datastore/datastore.py') diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index 7af2e93..1fe9cc3 100644 --- a/sugar/datastore/datastore.py +++ b/sugar/datastore/datastore.py @@ -63,6 +63,9 @@ class DSMetadata(gobject.GObject): def get_dictionary(self): return self._props + def copy(self): + return DSMetadata(self._props.copy()) + class DSObject(object): def __init__(self, object_id, metadata=None, file_path=None): self.object_id = object_id @@ -161,6 +164,9 @@ class DSObject(object): 'Please call DSObject.destroy() before disposing it.') self.destroy() + def copy(self): + return DSObject(None, self._metadata.copy(), self._file_path) + def get(object_id): logging.debug('datastore.get') metadata = dbus_helpers.get_properties(object_id) @@ -224,6 +230,16 @@ def find(query, sorting=None, limit=None, offset=None, reply_handler=None, return objects, total_count +def copy(jobject, mount_point): + + new_jobject = jobject.copy() + new_jobject.metadata['mountpoint'] = mount_point + + # this will cause the file be retrieved from the DS + new_jobject.file_path = jobject.file_path + + write(new_jobject) + def mount(uri, options): return dbus_helpers.mount(uri, options) -- cgit v0.9.1