[Sugar-devel] [PATCH 3/7] metadatastore: store/change files on disk defensively #2317

Martin Langhoff martin at laptop.org
Mon Oct 1 17:47:13 EDT 2012


On Mon, Oct 1, 2012 at 12:59 PM, Martin Langhoff <martin at laptop.org> wrote:
>> From that section I understand that we are encoding the data into
>> utf-8 if value is "unicode", but if it is just a "basestring", why we
>> are doing "str()"?
>
> That's actually not changed code.. only changes indentation. I don't
> like it, I very seriously don't like it, but fixing the problem is
> outside the scope of this patchset. Why do we do str(), I don't know.
> I believe it's a noop in this case.

Actually, I know why. AIUI, data types coming from dbus can be ints
and floats. And that var is coming from dbus. So we cannot write
directly to a file without a cast.

See http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html#data-types

> The problem is that we are dealing with some raw binary data (ie:
> thumbnails) as if it were a string. You can get away with that as long
> as your string ops are 8-bit clean. Once we move to utf-8, they won't
> be.

That table also indicates, in the 'notes' column, that all string data
must be valid utf8. I don't know how we are getting the thumbnails
through, and it seems likely that at some point it'll break, perhaps
due to changes in dbus.

We must change the thumbnail passing to be in a file, not too far in the future.

cheers,



m
-- 
 martin at laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff


More information about the Sugar-devel mailing list