Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/datastore/dbus_helpers.py
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-09-08 01:53:32 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-09-08 01:53:32 (GMT)
commit9e2a9c4c025b492169fe244c4a443d1b63b50968 (patch)
tree6995c72387024d26f4aad879b4d31f33c364fe6a /sugar/datastore/dbus_helpers.py
parent434483f54a3a5477077a96167f17ee6e19e2a0e7 (diff)
Support moving of files to datastore when using write_file()
Using the transfer_ownership argument, activities using the default activity datastore integration methods (namely write_file) will now tell the datastore that it can move the files by default. This reduces the copies required, which is slow on flash. For activities not using the standard APIs (Record, etc), the datastore bindings allow the activity to specify when ownership should transfer.
Diffstat (limited to 'sugar/datastore/dbus_helpers.py')
-rw-r--r--sugar/datastore/dbus_helpers.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/sugar/datastore/dbus_helpers.py b/sugar/datastore/dbus_helpers.py
index 6625d22..88dfb6d 100644
--- a/sugar/datastore/dbus_helpers.py
+++ b/sugar/datastore/dbus_helpers.py
@@ -40,20 +40,26 @@ def _get_data_store():
DS_DBUS_INTERFACE)
return _data_store
-def create(properties, filename):
- object_id = _get_data_store().create(dbus.Dictionary(properties), filename)
+def create(properties, filename, transfer_ownership=False):
+ object_id = _get_data_store().create(dbus.Dictionary(properties), filename,
+ transfer_ownership)
logging.debug('dbus_helpers.create: ' + object_id)
return object_id
-def update(uid, properties, filename, reply_handler=None, error_handler=None, timeout=-1):
- logging.debug('dbus_helpers.update: %s, %s, %s' % (uid, filename, properties))
+def update(uid, properties, filename, transfer_ownership=False,
+ reply_handler=None, error_handler=None, timeout=-1):
+ debug_props = properties.copy()
+ if debug_props.has_key("preview"):
+ debug_props["preview"] = "<omitted>"
+ logging.debug('dbus_helpers.update: %s, %s, %s, %s' % (uid, filename, debug_props, transfer_ownership))
if reply_handler and error_handler:
_get_data_store().update(uid, dbus.Dictionary(properties), filename,
+ transfer_ownership,
reply_handler=reply_handler,
error_handler=error_handler,
timeout=timeout)
else:
- _get_data_store().update(uid, dbus.Dictionary(properties), filename)
+ _get_data_store().update(uid, dbus.Dictionary(properties), filename, transfer_ownership)
def delete(uid):
logging.debug('dbus_helpers.delete: %r' % uid)