Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/activity/activityhandle.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/activity/activityhandle.py')
-rw-r--r--src/sugar/activity/activityhandle.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/sugar/activity/activityhandle.py b/src/sugar/activity/activityhandle.py
index 2153ffb..ac4ee0b 100644
--- a/src/sugar/activity/activityhandle.py
+++ b/src/sugar/activity/activityhandle.py
@@ -18,20 +18,20 @@
"""
STABLE.
"""
+import logging
+
class ActivityHandle(object):
"""Data structure storing simple activity metadata"""
def __init__(
- self, activity_id=None, tree_id=None, version_id=None, uri=None
+ self, activity_id=None, object_id=None, uri=None
):
"""Initialise the handle from activity_id
activity_id -- unique id for the activity to be
created
- tree_id -- identity of the journal object
- associated with the activity.
- version_id -- the exact version of the journal
- object.
+ object_id -- tuple of tree_id and version_id of
+ the journal object associated with the activity.
When you resume an activity from the journal
the tree_id and version_id will be passed in.
@@ -44,14 +44,14 @@ class ActivityHandle(object):
example or web pages)
"""
self.activity_id = activity_id
- self.tree_id = tree_id
- self.version_id = version_id
+ self.object_id = object_id
self.uri = uri
def get_dict(self):
"""Retrieve our settings as a dictionary"""
result = { 'activity_id' : self.activity_id }
if self.tree_id:
+ result['object_id'] = self.object_id
result['tree_id'] = self.tree_id
result['version_id'] = self.version_id
if self.uri:
@@ -59,12 +59,30 @@ class ActivityHandle(object):
return result
+ def get_object_id(self) :
+ logging.debug("AH.get_object_id %r %r" % (self.tree_id, self.version_id))
+ if self.tree_id is None and self.version_id is None :
+ logging.debug("AH.get_object_id returning None")
+ return None
+
+ return (self.tree_id, self.version_id)
+
+ def set_object_id(self, object_id) :
+ self.tree_id, self.version_id = object_id or (None, None)
+
+ object_id = property(get_object_id, set_object_id)
+
+
def create_from_dict(handle_dict):
"""Create a handle from a dictionary of parameters"""
+ if handle_dict.get('object_id') :
+ handle_dict = dict(handle_dict)
+ handle_dict['tree_id'], handle_dict['version_id'] = handle_dict['object_id']
+
result = ActivityHandle(
handle_dict['activity_id'],
- tree_id = handle_dict.get('tree_id'),
- version_id = handle_dict.get('version_id'),
+ object_id = (handle_dict.get('tree_id'),
+ handle_dict.get('version_id')),
uri = handle_dict.get('uri'),
)
return result