How to prevent a shared document from downloading more than once?

2009-03-16 Thread James Simmons
It looks like my last naive question about collaboration started a 
discussion so notable that Walter Bender wrote about it in his blog 
http://walterbender.org/.  Let's see what you can do with this one.

Both my Activities, Read ETexts and View Slides, have document sharing 
code mostly copied from the core Read activity.  Currently this works 
just fine in both Activities, with only one problem.  Suppose someone 
shares a document with me, I receive it successfully, then quit, causing 
the copied document to be saved in my Journal.  Now if the original user 
stops sharing (closes his copy of the Activity) and I resume mine I get 
my stored copy and all is wonderful.  But suppose the original user 
*doesn't* stop sharing.  I resume my copy, see the stored copy on the 
screen, but I *still* download the document my friend is sharing.  I 
don't want to do that.  It wastes bandwidth and time and causes *keep* 
errors when you close the document.

Now the problem is, the sharing code is in the __init__() method, which 
always runs before anything else, and the read_file() method, which runs 
when you resume from the Journal, unfortunately *after* the Activity has 
already decided it needs to download the file.  I need a way for the 
__init__ method to realize that it doesn't need to download the file, or 
some other way to deal with the problem.

Thanks,

James Simmons


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: How to prevent a shared document from downloading more than once?

2009-03-16 Thread Wade Brainerd
I wrote a brief proposal a few weeks ago for an improvement to the
collab API that might help this problem.  The discussion is in
http://dev.sugarlabs.org/ticket/428.  Aleksey Lim wrote an example
implementation of this Cartoon Builder.

The idea is that rather than having overlapping entry points for
intializing activity instances: __init__ (new instance but all the
others also), read_file (resume instance), shared_cb (join, share
instance) we have a new set of callbacks which are invoked *after*
__init__.

new_instance
resume_instance
share_instance(is_initiator) - could be split into join_instance and
share_instance?
save_instance

alsroot's implementation is below, and it calls the old interfaces
when they are not present.

http://git.sugarlabs.org/projects/cartoon-builder/repos/mainline/blobs/master/shared.py

Perhaps these new callbacks could be integrated into Sugar 0.86?  But
in the meantime, you can always just add Aleksey's shared.py into your
activity.

Cheers,
Wade




On Mon, Mar 16, 2009 at 11:29 AM, James Simmons
jim.simm...@walgreens.com wrote:
 It looks like my last naive question about collaboration started a
 discussion so notable that Walter Bender wrote about it in his blog
 http://walterbender.org/.  Let's see what you can do with this one.

 Both my Activities, Read ETexts and View Slides, have document sharing
 code mostly copied from the core Read activity.  Currently this works
 just fine in both Activities, with only one problem.  Suppose someone
 shares a document with me, I receive it successfully, then quit, causing
 the copied document to be saved in my Journal.  Now if the original user
 stops sharing (closes his copy of the Activity) and I resume mine I get
 my stored copy and all is wonderful.  But suppose the original user
 *doesn't* stop sharing.  I resume my copy, see the stored copy on the
 screen, but I *still* download the document my friend is sharing.  I
 don't want to do that.  It wastes bandwidth and time and causes *keep*
 errors when you close the document.

 Now the problem is, the sharing code is in the __init__() method, which
 always runs before anything else, and the read_file() method, which runs
 when you resume from the Journal, unfortunately *after* the Activity has
 already decided it needs to download the file.  I need a way for the
 __init__ method to realize that it doesn't need to download the file, or
 some other way to deal with the problem.

 Thanks,

 James Simmons


 ___
 Devel mailing list
 Devel@lists.laptop.org
 http://lists.laptop.org/listinfo/devel

___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: How to prevent a shared document from downloading more than once?

2009-03-16 Thread James Simmons
Great, once again I'm going to be indebted to Aleksey Lim.  I'll give 
shared.py a try as soon as I can.

James Simmons


Wade Brainerd wrote:
 I wrote a brief proposal a few weeks ago for an improvement to the
 collab API that might help this problem.  The discussion is in
 http://dev.sugarlabs.org/ticket/428.  Aleksey Lim wrote an example
 implementation of this Cartoon Builder.

 The idea is that rather than having overlapping entry points for
 intializing activity instances: __init__ (new instance but all the
 others also), read_file (resume instance), shared_cb (join, share
 instance) we have a new set of callbacks which are invoked *after*
 __init__.

 new_instance
 resume_instance
 share_instance(is_initiator) - could be split into join_instance and
 share_instance?
 save_instance

 alsroot's implementation is below, and it calls the old interfaces
 when they are not present.

 http://git.sugarlabs.org/projects/cartoon-builder/repos/mainline/blobs/master/shared.py

 Perhaps these new callbacks could be integrated into Sugar 0.86?  But
 in the meantime, you can always just add Aleksey's shared.py into your
 activity.

 Cheers,
 Wade




 On Mon, Mar 16, 2009 at 11:29 AM, James Simmons
 jim.simm...@walgreens.com wrote:
   
 It looks like my last naive question about collaboration started a
 discussion so notable that Walter Bender wrote about it in his blog
 http://walterbender.org/.  Let's see what you can do with this one.

 Both my Activities, Read ETexts and View Slides, have document sharing
 code mostly copied from the core Read activity.  Currently this works
 just fine in both Activities, with only one problem.  Suppose someone
 shares a document with me, I receive it successfully, then quit, causing
 the copied document to be saved in my Journal.  Now if the original user
 stops sharing (closes his copy of the Activity) and I resume mine I get
 my stored copy and all is wonderful.  But suppose the original user
 *doesn't* stop sharing.  I resume my copy, see the stored copy on the
 screen, but I *still* download the document my friend is sharing.  I
 don't want to do that.  It wastes bandwidth and time and causes *keep*
 errors when you close the document.

 Now the problem is, the sharing code is in the __init__() method, which
 always runs before anything else, and the read_file() method, which runs
 when you resume from the Journal, unfortunately *after* the Activity has
 already decided it needs to download the file.  I need a way for the
 __init__ method to realize that it doesn't need to download the file, or
 some other way to deal with the problem.

 Thanks,

 James Simmons


 ___
 Devel mailing list
 Devel@lists.laptop.org
 http://lists.laptop.org/listinfo/devel

 


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: How to prevent a shared document from downloading more than once?

2009-03-16 Thread Gary C Martin
On 16 Mar 2009, at 15:29, James Simmons wrote:

 It looks like my last naive question about collaboration started a
 discussion so notable that Walter Bender wrote about it in his blog
 http://walterbender.org/.  Let's see what you can do with this one.

 Both my Activities, Read ETexts and View Slides, have document sharing
 code mostly copied from the core Read activity.  Currently this works
 just fine in both Activities, with only one problem.  Suppose someone
 shares a document with me, I receive it successfully, then quit,  
 causing
 the copied document to be saved in my Journal.  Now if the original  
 user
 stops sharing (closes his copy of the Activity) and I resume mine I  
 get
 my stored copy and all is wonderful.  But suppose the original user
 *doesn't* stop sharing.  I resume my copy, see the stored copy on the
 screen, but I *still* download the document my friend is sharing.  I
 don't want to do that.  It wastes bandwidth and time and causes *keep*
 errors when you close the document.

 Now the problem is, the sharing code is in the __init__() method,  
 which
 always runs before anything else, and the read_file() method, which  
 runs
 when you resume from the Journal, unfortunately *after* the Activity  
 has
 already decided it needs to download the file.  I need a way for the
 __init__ method to realize that it doesn't need to download the  
 file, or
 some other way to deal with the problem.

Sorry, I'm likely missing something obvious here, but could the  
__init__() check to see if it was resumed from journal, and use that  
as a cue to read the local file? If the file is incomplete/corrupt  
you'd need back out and get the file remotely:

 if handle.object_id == None:
 # Launched from home.
 ... ...
 else:
 # Journal resume, don't download, use local file.
 ... ...

Regards,
--Gary

P.S. This coming from a man who hasn't implemented collaboration in  
any of his activities yet.

 Thanks,

 James Simmons


 ___
 Devel mailing list
 Devel@lists.laptop.org
 http://lists.laptop.org/listinfo/devel

___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: How to prevent a shared document from downloading more than once?

2009-03-16 Thread James Simmons
Gary,

I'm going to try your suggestion first, since it seems like something I 
could do with just a couple of lines.

I'm remembering another problem I have with my stuff, which is how to 
give a shared document the correct name in the Journal that receives 
it.  In the Read activity it seems it is getting the title of the 
document from metadata in the PDF file itself, which I cannot do because 
my documents are just Zip files or text files.  So my Journal entry 
reads Read EText Activity or View Slides Activity.

This is what I want to happen:

1).  Someone has a document to share, say the book Jack and the 
Giants, which is a zip file containing scanned in images.  He goes to 
the neighborhood view and sees his friend Billy is there, and he invites 
Billy to share the book.

2).  Billy goes into his own neighborhood view and sees the View Slides 
icon, indicating that someone has a slide collection to share.  He 
mouses over the icon and sees that the collection is named Jack and the 
Giants.  Sounds cool.  He clicks on the icon and starts receiving the 
book.  When it is fully downloaded he reads it a bit, then exits the 
View Slides Activity.

3).  The next time he goes to the Journal he sees an entry with the 
View Slides icon named Jack and the Giants.

I know how to update the Journal title from Python.  The missing piece 
is how do I find out the name of the shared document?  It shows the name 
when we invite Billy to share it, so how do I get that name?

James Simmons



Gary C Martin wrote:
 On 16 Mar 2009, at 15:29, James Simmons wrote:

 It looks like my last naive question about collaboration started a
 discussion so notable that Walter Bender wrote about it in his blog
 http://walterbender.org/.  Let's see what you can do with this one.

 Both my Activities, Read ETexts and View Slides, have document sharing
 code mostly copied from the core Read activity.  Currently this works
 just fine in both Activities, with only one problem.  Suppose someone
 shares a document with me, I receive it successfully, then quit, causing
 the copied document to be saved in my Journal.  Now if the original user
 stops sharing (closes his copy of the Activity) and I resume mine I get
 my stored copy and all is wonderful.  But suppose the original user
 *doesn't* stop sharing.  I resume my copy, see the stored copy on the
 screen, but I *still* download the document my friend is sharing.  I
 don't want to do that.  It wastes bandwidth and time and causes *keep*
 errors when you close the document.

 Now the problem is, the sharing code is in the __init__() method, which
 always runs before anything else, and the read_file() method, which runs
 when you resume from the Journal, unfortunately *after* the Activity has
 already decided it needs to download the file.  I need a way for the
 __init__ method to realize that it doesn't need to download the file, or
 some other way to deal with the problem.

 Sorry, I'm likely missing something obvious here, but could the 
 __init__() check to see if it was resumed from journal, and use that 
 as a cue to read the local file? If the file is incomplete/corrupt 
 you'd need back out and get the file remotely:

 if handle.object_id == None:
 # Launched from home.
 ... ...
 else:
 # Journal resume, don't download, use local file.
 ... ...

 Regards,
 --Gary

 P.S. This coming from a man who hasn't implemented collaboration in 
 any of his activities yet.

 Thanks,

 James Simmons


 ___
 Devel mailing list
 Devel@lists.laptop.org
 http://lists.laptop.org/listinfo/devel



___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel