Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorDan Williams <dcbw@localhost.localdomain>2006-12-20 19:04:52 (GMT)
committer Dan Williams <dcbw@localhost.localdomain>2006-12-20 19:04:52 (GMT)
commite586cd66c005e7ccb2af7244fe8be393befcf010 (patch)
treef2c62f57d2f53fa8e900c3bfd32a41d23cb14507 /sugar
parente023d1c3451b8e32c5607f774f3187fd21cb9d7d (diff)
Add activity objects to the data store
Diffstat (limited to 'sugar')
-rw-r--r--sugar/datastore/datastore.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/sugar/datastore/datastore.py b/sugar/datastore/datastore.py
index 3aa007e..7a77687 100644
--- a/sugar/datastore/datastore.py
+++ b/sugar/datastore/datastore.py
@@ -15,6 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import dbus, dbus.glib, gobject
+from sugar import util
class ObjectCache(object):
def __init__(self):
@@ -159,11 +160,27 @@ class DataStore(gobject.GObject):
# FIXME
pass
- def get(self, uid):
- return self._new_object(self._ds.get(int(uid)))
-
- def create(self, data, prop_dict={}):
- op = self._ds.create(dbus.ByteArray(data), dbus.Dictionary(prop_dict))
+ def get(self, uid=None, activity_id=None):
+ if not activity_id and not uid:
+ raise ValueError("At least one of activity_id or uid must be specified")
+ if activity_id and uid:
+ raise ValueError("Only one of activity_id or uid can be specified")
+ if activity_id:
+ if not util.validate_activity_id(activity_id):
+ raise ValueError("activity_id must be valid")
+ return self._new_object(self._ds.getActivityObject(activity_id))
+ elif uid:
+ if not len(uid):
+ raise ValueError("uid must be valid")
+ return self._new_object(self._ds.get(int(uid)))
+ raise RuntimeError("At least one of activity_id or uid must be specified")
+
+ def create(self, data, prop_dict={}, activity_id=None):
+ if activity_id and not util.validate_activity_id(activity_id):
+ raise ValueError("activity_id must be valid")
+ if not activity_id:
+ activity_id = ""
+ op = self._ds.create(dbus.ByteArray(data), dbus.Dictionary(prop_dict), activity_id)
return self._new_object(op)
def delete(self, obj):