Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-08-13 23:37:21 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-08-13 23:37:21 (GMT)
commite88e82fee42d8775d40dfa45dba6cedea9479b74 (patch)
tree4e9ab484de24c71ecf39b5a20e6bf4e5e3ebcc21
parenta2220a982e3e2ee17f7afefa07dfd81269b6dba3 (diff)
Supplement a2220a982e3e2ee17f7afefa07dfd81269b6dba3 commit
-rw-r--r--sugar_network/local/dbus_datastore.py24
-rw-r--r--sugar_network/local/dbus_network.py4
-rw-r--r--sugar_network/toolkit/dbus_thread.py8
3 files changed, 19 insertions, 17 deletions
diff --git a/sugar_network/local/dbus_datastore.py b/sugar_network/local/dbus_datastore.py
index d00ee98..5df01ab 100644
--- a/sugar_network/local/dbus_datastore.py
+++ b/sugar_network/local/dbus_datastore.py
@@ -130,7 +130,7 @@ class Datastore(dbus_thread.Service):
async_callbacks=('reply_cb', 'error_cb'))
def get_filename(self, uid, reply_cb, error_cb):
- def reply(meta):
+ def reply(meta=None):
if meta is None:
path = ''
else:
@@ -149,7 +149,7 @@ class Datastore(dbus_thread.Service):
async_callbacks=('reply_cb', 'error_cb'))
def get_properties(self, uid, reply_cb, error_cb):
- def reply(blob, props):
+ def reply(props, blob=None):
props = datastore.encode_props(props, None)
if blob is not None:
with file(blob['path'], 'rb') as f:
@@ -217,22 +217,22 @@ class Datastore(dbus_thread.Service):
props['filesize'] = '0'
props = datastore.decode_props(props)
- if http_method == 'PUT' and 'guid' in props:
- # DataStore clients might send guid in updated props
- props.pop('guid')
+ args = [http_method, blobs, reply_cb, error_cb]
+
+ if http_method == 'PUT':
+ if 'guid' in props:
+ # DataStore clients might send guid in updated props
+ props.pop('guid')
+ args += [kwargs['guid']]
self.call(self._set_blob, error_cb, method=http_method, mountpoint='~',
- document='artifact', content=props, args=[http_method,
- kwargs.get('guid'), blobs, reply_cb, error_cb],
- **kwargs)
+ document='artifact', content=props, args=args, **kwargs)
- def _set_blob(self, reply, http_method, guid, blobs, reply_cb, error_cb):
- if not guid:
- guid = reply
+ def _set_blob(self, http_method, blobs, reply_cb, error_cb, guid):
if blobs:
self.call(self._set_blob, error_cb, method='PUT',
mountpoint='~', document='artifact', guid=guid,
- args=[http_method, guid, blobs, reply_cb, error_cb],
+ args=[http_method, blobs, reply_cb, error_cb, guid],
**blobs.pop())
elif http_method == 'POST':
reply_cb(guid)
diff --git a/sugar_network/local/dbus_network.py b/sugar_network/local/dbus_network.py
index b4a6e10..3f9c33f 100644
--- a/sugar_network/local/dbus_network.py
+++ b/sugar_network/local/dbus_network.py
@@ -42,8 +42,8 @@ class Network(dbus_thread.Service):
@method(_INTERFACE, in_signature='s', out_signature='s',
async_callbacks=('reply_cb', 'error_cb'))
def Call(self, cmd, reply_cb, error_cb):
- self.call(lambda response: reply_cb(json.dumps(response)), error_cb,
- **json.loads(cmd))
+ self.call(lambda response=None: reply_cb(json.dumps(response)),
+ error_cb, **json.loads(cmd))
@method(_INTERFACE, in_signature='sssas', out_signature='a{sv}',
async_callbacks=('reply_cb', 'error_cb'))
diff --git a/sugar_network/toolkit/dbus_thread.py b/sugar_network/toolkit/dbus_thread.py
index c9f322b..b811a80 100644
--- a/sugar_network/toolkit/dbus_thread.py
+++ b/sugar_network/toolkit/dbus_thread.py
@@ -51,11 +51,13 @@ def start(mountset):
reply = mountset.call(request)
except Exception, error:
util.exception(_logger, 'DBus %r request failed', request)
- if reply_cb is not None:
+ if error_cb is not None:
spawn(error_cb, error)
else:
if reply_cb is not None:
- spawn(reply_cb, reply, *(args or []))
+ if reply is not None:
+ args += [reply]
+ spawn(reply_cb, *args)
finally:
mountset.disconnect(handle_event)
spawn(mainloop.quit)
@@ -94,7 +96,7 @@ class Service(Object):
request.content = content
request.content_stream = content_stream
request.content_length = content_length
- _call_queue.put((request, reply_cb, error_cb, args))
+ _call_queue.put((request, reply_cb, error_cb, args or []))
def handle_event(self, event):
"""Handle, in child thread, events gotten from parent thread."""