diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py index 7af2e939..1fe9cc3f 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)