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

Samuel Greenfeld greenfeld at laptop.org
Thu Feb 10 13:20:47 EST 2011


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 <erikb at mediamods.com
> <mailto:erikb at mediamods.com>> 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 at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



More information about the Sugar-devel mailing list