[Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Erik Blankinship
How can I determine if a file loaded with a sugar object chooser was
selected from the datastore or from an external storage device?

dsobject = chooser.get_selected_object( )
logger.debug( "opening %s" % dsobject.file_path )

On an xo, opening a file from the usb results in something like:

opening /home/olpc/.sugar/default/data/rawobject ...

... which is not too different from opening a file from the journal.  Is
there some additional metadata to look at to determine where the file came
from?
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Sascha Silbe
Excerpts from Erik Blankinship's message of Thu Feb 10 17:11:40 +0100 2011:

> How can I determine if a file loaded with a sugar object chooser was
> selected from the datastore or from an external storage device?

On Sugar 0.84+, there is no difference. Objects on external storage get
copied to the data store first.

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Erik Blankinship
>
>
> > How can I determine if a file loaded with a sugar object chooser was
> > selected from the datastore or from an external storage device?
>
> On Sugar 0.84+, there is no difference. Objects on external storage get
> copied to the data store first.
>
>
But the objects don't get copied to the Journal (or at least I don't see
them there).

Maybe I should rephrase my question: how can I know if the selected object
was loaded from the Journal?

What I am trying to do:
If an object is loaded from an external device, I want to add a copy of that
object to the user's journal.
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Erik Blankinship
On Thu, Feb 10, 2011 at 11:30 AM, Erik Blankinship wrote:

>
>> > How can I determine if a file loaded with a sugar object chooser was
>> > selected from the datastore or from an external storage device?
>>
>> On Sugar 0.84+, there is no difference. Objects on external storage get
>> copied to the data store first.
>>
>>
> But the objects don't get copied to the Journal (or at least I don't see
> them there).
>
> Maybe I should rephrase my question: how can I know if the selected object
> was loaded from the Journal?
>
> What I am trying to do:
> If an object is loaded from an external device, I want to add a copy of
> that object to the user's journal.
>


How does this idea look to the community?  Seems hackish to me, but might
work?

errything = datastore.find( {} )[0]

...

dsobject = chooser.get_selected_object( )

from_journal = False
for errything_ds in errything:
 if errything_ds.object_id == dsobject.object_id:
  from_journal = True
  break
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Gonzalo Odiard
Please, don't do it. :(

Gonzalo

How does this idea look to the community?  Seems hackish to me, but might
work?

>
> errything = datastore.find( {} )[0]
>
> ...
>
> dsobject = chooser.get_selected_object( )
>
> from_journal = False
> for errything_ds in errything:
>  if errything_ds.object_id == dsobject.object_id:
>   from_journal = True
>   break
>
>
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Samuel Greenfeld
As far as I know there really is no need; when your activity saves state
(when exiting, etc.), it should save the copied file as part of the
activity's journal entry.

At least this is how it has always worked with Jukebox & Read.

(As a side note, the Journal description for a copied item often states
the path where it came from, but I would not rely on this to tell you
that it came from an external source.  The description or this "feature"
could change at any time.)

---
SJG


On 02/10/11 12:57, Erik Blankinship wrote:
> 
> 
> On Thu, Feb 10, 2011 at 11:30 AM, Erik Blankinship  > wrote:
> 
> 
> > How can I determine if a file loaded with a sugar object
> chooser was
> > selected from the datastore or from an external storage device?
> 
> On Sugar 0.84+, there is no difference. Objects on external
> storage get
> copied to the data store first.
> 
> 
> But the objects don't get copied to the Journal (or at least I don't
> see them there).  
> 
> Maybe I should rephrase my question: how can I know if the selected
> object was loaded from the Journal?
> 
> What I am trying to do:
> If an object is loaded from an external device, I want to add a copy
> of that object to the user's journal.
> 
> 
> 
> How does this idea look to the community?  Seems hackish to me, but
> might work?
> 
> errything = datastore.find( {} )[0]
> 
> ...
> 
> dsobject = chooser.get_selected_object( )
> 
> from_journal = False
> for errything_ds in errything:
>  if errything_ds.object_id == dsobject.object_id:
>   from_journal = True
>   break
> 
> 
> 
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-10 Thread Erik Blankinship
My suggestion appears to work.  What would the community suggest as a better 
solution using the existing object chooser?



On Feb 10, 2011, at 1:07 PM, Gonzalo Odiard  wrote:

> Please, don't do it. :(
> 
> Gonzalo
> 
> How does this idea look to the community?  Seems hackish to me, but might 
> work?
> 
> errything = datastore.find( {} )[0]
> 
> ...
> 
> dsobject = chooser.get_selected_object( )
> 
> from_journal = False
> for errything_ds in errything:
>  if errything_ds.object_id == dsobject.object_id:
>   from_journal = True
>   break
> 
> 
> ___
> Sugar-devel mailing list
> Sugar-devel@lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
> 
> 
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] determine origin of file selected from an object chooser?

2011-02-11 Thread Erik Blankinship
On Thu, Feb 10, 2011 at 1:20 PM, Samuel Greenfeld 
 wrote:

> As far as I know there really is no need; when your activity saves state
> (when exiting, etc.), it should save the copied file as part of the
> activity's journal entry.
>
> At least this is how it has always worked with Jukebox & Read.
>
>
Do I understand what you've written correctly?  If I open and play a .wav
file located on a usb stick in JukeBox, the wav file's data is serialized
into the activity instance on write_file?

I just played with jukebox and it does not seem to work this way -- I loaded
in a .wav file, played it, and then closed my activity instance.  I removed
the usb stick and relaunched my jukebox activity instance.  Jukebox was not
able to play my file.  Also, my file was not added to the journal.

Let me try to rephrase my question in terms of the jukebox activity: If I
wanted to add an option to jukebox which "imports" wav files selected with
the object chooser into my journal, what would be the best way to detect if
the files were already in the journal or not?
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel