[sugar] Putting stuff inside the datastore for non-activities

Sayamindu Dasgupta sayamindu at gmail.com
Fri Oct 10 18:53:47 EDT 2008


On Sat, Oct 11, 2008 at 3:06 AM, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> Am 10.10.2008 um 23:24 schrieb Sayamindu Dasgupta:
>
>> On Sat, Oct 11, 2008 at 2:24 AM, Marco Pesenti Gritti
>> <mpgritti at gmail.com> wrote:
>>> On Fri, Oct 10, 2008 at 10:43 PM, Sayamindu Dasgupta
>>> <sayamindu at gmail.com> wrote:
>>>> Hello,
>>>> The sugar-almanac has a nice guide on how put stuff inside the
>>>> datastore programmatically
>>>> (http://wiki.laptop.org/go/Sugar.datastore.datastore#How_do_I_save_a_simple_text_file_to_the_datastore.3F
>>>> )
>>>> However, it makes the assumption that the method is being called
>>>> from
>>>> a sugar activity. (file_path =
>>>> os.path.join(self.get_activity_root(),
>>>> 'instance', filename))
>>>> Can anyone tell me where to put in a file if I am not calling this
>>>> from within an activity ?
>>>
>>> afaik you can put it wherever you like. copy-to-journal for example
>>> is
>>> just writing an existing file to the DS...
>>>
>>
>> Yes - but in my case, I have a file in tmp (created by mozplugger)
>> which I need to move to the journal. I can't keep the file in tmp (as
>> in copy-to-journal), since it may get deleted, and I can't write in
>> random places in /home/olpc (rainbow might not like that). In that
>> case, what would be the safest place to store the file ?
>
>
> The datastore will make a copy - don't worry, just hand it the file
> from /tmp.
>
> Btw, rainbow only isolates activities, so if your code is not running
> from an activity you can freely write in the olpc home directory.
>
> However, if I understand correctly you are in mozplugger which is
> running inside the Browse activity so you could use the activity root
> directory if indeed needed (see http://wiki.laptop.org/go/Low-level_Activity_API#File_Access
>  ).
>

Thanks for the tip. It looks like for remote files, mozplugger is
creating the tmpfile in <instancedir>/tmp, and somehow, the ds is not
creating a copy of that file (I get a journal entry, but there's no
file which is loaded subsequently by Read)
Disabling security, or saving a local file seems to work fine though.
I'm using the same code as in copy-to-journal

Cheers,
Sayamindu

-- 
Sayamindu Dasgupta
[http://sayamindu.randomink.org/ramblings]


More information about the Sugar mailing list