Add a copy method to the datastore wrapper.

This commit is contained in:
Tomeu Vizoso 2007-08-27 19:44:49 +02:00
parent 294a5231b9
commit 1430fdc24f

View File

@ -63,6 +63,9 @@ class DSMetadata(gobject.GObject):
def get_dictionary(self): def get_dictionary(self):
return self._props return self._props
def copy(self):
return DSMetadata(self._props.copy())
class DSObject(object): class DSObject(object):
def __init__(self, object_id, metadata=None, file_path=None): def __init__(self, object_id, metadata=None, file_path=None):
self.object_id = object_id self.object_id = object_id
@ -161,6 +164,9 @@ class DSObject(object):
'Please call DSObject.destroy() before disposing it.') 'Please call DSObject.destroy() before disposing it.')
self.destroy() self.destroy()
def copy(self):
return DSObject(None, self._metadata.copy(), self._file_path)
def get(object_id): def get(object_id):
logging.debug('datastore.get') logging.debug('datastore.get')
metadata = dbus_helpers.get_properties(object_id) 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 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): def mount(uri, options):
return dbus_helpers.mount(uri, options) return dbus_helpers.mount(uri, options)