[sugar] Datastore: uid, entry_id, object_id, activity_id ?

Tomeu Vizoso tomeu
Mon Mar 10 04:58:36 EDT 2008


On Sun, Mar 9, 2008 at 11:40 PM, Benjamin M. Schwartz
<bmschwar at fas.harvard.edu> wrote:
> Tomeu Vizoso wrote:
>  | On Sat, Mar 8, 2008 at 11:17 PM, Benjamin M. Schwartz
>  | <bmschwar at fas.harvard.edu> wrote:
>  |>  According to this page:
>  http://wiki.laptop.org/go/Journal_entry_bundles ...
>  |>
>  |>  Each journal entry has a unique "uid".  This 'uid' is listed in its
>  |>  metadata, and a conforming Journal Entry Bundle uses the uid calue to name
>  |>  various components of the bundle.  However, the DSMetadata object
>  |>  retrieved by calling dsobject.get_metadata() does not have a 'uid' key.
>  |>  What is the uid, and, given a DSObject, how am I supposed to determine it?
>  |
>  | Use the object_id attribute of the DSObject:
>  |
>  | http://tinyurl.com/2sgulm
>  |
>  http://dev.laptop.org/git?p=sugar-toolkit;a=blob;f=sugar/datastore/datastore.py;h=334c866a6783463ff53146a35300fd1191bebcb1;hb=HEAD#l84
>  |
>
>  OK.  On http://wiki.laptop.org/go/Journal_entry_bundles, you gave an
>  example of activity metadata:
>
>  {"activity_id":"67d38ab406143c6b6b023896e9efa8fc7706ff57",
>  ~ "title_set_by_user":"0",
>  ~ "uid":"15b114ad-1eed-461f-9315-129bba41ce2d",
>  ~ "vid":"1.0",
>  ~ "title":"Paint Activity",
>  ~ "timestamp":"1192547469",
>  ~ "activity":"org.laptop.Oficina",
>  ~ "filename":"",
>  ~ "icon-color":"#00588C,#00EA11",
>  ~ "mtime":"2007-10-16T17:11:09",
>  ~ "mountpoint":"18d7246f-72a4-4089-b7dc-2dbdf2b81aa6",
>  ~ "keep":"0",
>  ~ "mime_type":"image/png",
>  ~ "preview":"15b114ad-1eed-461f-9315-129bba41ce2d"}
>
>  This metadata dict contains a 'uid' key.  Currently, the metadata
>  associated with a DSObject has no such key.  Is this a bug in the
>  datastore, a problem with that wiki page, or a misunderstanding on my part?

Well, the metadata word is being used with four meanings:

1. conceptually, key-value pairs that help describe an entry.
2. dictionary returned by the datastore,
3. dictionary contained by DSObject,
4. dictionary in a json file in serialized entries.

In 2 and 4, the uid is contained as part of the metadata. Regarding 1,
I would say that the key is not part of the metadata. And that's the
reason why the uid lives in DSObject.object_id and not in
DSObject.metadata (3).

I think that metadata can be changed during the live of a journal
entry, but the uid will always stay the same. If the uid was part of
the metadata and the user of the API changed it, would be clear that a
new entry would be created? I think this would complicate
unnecessarily the API.

So we have an inconsistency here between the different parts of the
system that expose the metadata of a journal entry. We also have the
same inconsistency inside the low level DS API, as update() accepts
both an uid parameter and a metadata dict.

So, in my opinion the uid should not be considered part of the
metadata but given the current state of the DS it may not be the best
moment to do this change.

Regards,

Tomeu



More information about the Sugar-devel mailing list