[Sugar-devel] universal reference to datastore objects
Bert Freudenberg
bert at freudenbergs.de
Thu Mar 4 04:47:29 EST 2010
On 03.03.2010, at 14:50, Walter Bender wrote:
>
> This topic comes up now and again (e.g.,
> http://cscott.net/Publications/OLPC/ufrgs-talk.pdf). I raised it in
> the context of wanted to create SVG files with embedded image data.
> From #sugar:
>
> <walterbender> silbe: you are a DS/Journal guru... I have a question
> <walterbender> silbe: I generate svg files in TA and write them to
> the datastore as their own journal entry.
> <walterbender> silbe: works fine except I have a problem with embedded images.
> <walterbender> silbe: I use xlink:xml="file:///..." to refer to the
> path returned by dsobject.file_path, but that seems to be a temp.
> reference, so when I go back to the svg object later, the path is
> invalid
> <walterbender> silbe: is there a way to find the actual path to, say
> a png file in the datastore, that I can then reference, or do I need
> to copy the data to the filesystem in order to reliably refer to it.
> <silbe> walterbender: Would embedding the image data directly be a good option?
> <silbe> walterbender: or should it stay in sync with the copy in the
> data store?
> <walterbender> silbe: I suppose I could encode the data and put it
> into the SVG file itself... but it would be nice to be able to
> reference (sync) to the file--much more efficient.
> <walterbender> silbe: I do exactly that (embed images) in my HTML
> output in TA... but it makes the HTML code unreadable for kids
> <walterbender> silbe: maybe this needs to be resolved as part of a
> general DS rethink...
> <walterbender> silbe: we have a lot of work for you once you finish
> your thesis :)
> <silbe> walterbender: since you cannot rely on file names I can think
> of two options: a) use CID-references like in emails and resolve them
> inside TA or b) create symlinks (on each run of TA)
> <walterbender> silbe: the issue is not TA. I want to use TA to make
> SVGs that other activities can use.
> e.g., Browse
> <silbe> walterbender: The most portable way to do it is to embed the data then.
> <walterbender> silbe: yeah. I was afraid of that. Readability and
> efficiency get thrown out. I was hoping there was another way.
> <silbe> walterbender: with Browse using a zip bundle might work, but
> that'd duplicate the data again instead of referencing
> <walterbender> silbe: I suppose I could wrap the SVG into a zip
> bundle with the related images...
> <silbe> walterbender: we could invent a new URL (URI?) scheme to
> reference data store entries, but that would obviously need to be
> supported in each activity. We can add common code to parse & resolve
> those URLs, but the activities need to actually use that code (as the
> parts that reference other entries are activity-specific).
> <silbe> walterbender: How about discussing it (way to reference data
> store entries) on sugar-devel? If we can get consensus on how to do
> it, I'll give it a try. After doing some bug squashing, that is. :)
I'd be interested in having a general URL notation for datastore entries :)
On a slightly related note, I added a made-up scheme to Scratch. The Scratch folks prefer to not change their current UI which is strictly file-based. So I opted for making the Journal look like a local directory to the rest of the code.
Since I can only pass around strings but need to access the object id, title, and type of the entry, it looks like
"sugar:/title|object_id.extension"
The datastore access code just extracts the object_id, whereas the UI strips all but the title, and filters by extension.
I'm not proposing this as a general scheme obviously, it's rather special-purpose and not visible to users or even outside of Scratch.
But possibly it would be nice if the datastore URL scheme could (optionally) include a title and extension. At the very least it might make debugging easier ...
- Bert -
More information about the Sugar-devel
mailing list