<div dir="ltr">I am for a simple read/write solution, <div>add the following comments based in my experience with gtk activities.</div><div><br></div><div>* In gtk read is called in the map of the canvas. Is a little obscure</div>
<div>and can be a problem in some cases. By example, in activities where </div><div>you can start without a object and later select one with the object chooser.</div><div>Examples are Read and ImageViewer activities in the latest versions.</div>
<div>The problem was, adding a empty widget as a canvas triggered the read_file method.</div><div>May be we can add a flag to disable the automatic call to read_file.</div><div><br></div><div>* Some activities assume a object is available to start the collaboration,</div>
<div>then should be needed start the collaboration after read_file.</div><div>Right now, max_participants need be set before the toolbar  creation,</div><div>and later changes do not enable/disable the collaboration button,</div>
<div>then a case like this should be managed by the programmer.</div><div><br></div><div>Should be good read this old bug <a href="http://bugs.sugarlabs.org/ticket/568">http://bugs.sugarlabs.org/ticket/568</a></div><div>now we can start with a empty page.</div>
<div><br></div><div>I do not see problems with write_file. Activity class already have methods </div><div>like can_close() to enable validations if needed in the activity.</div><div><br></div><div>The gtk version show a very annoying alert when have a problem writing the file,</div>
<div>I think is a good idea :) should be worst if we lost data and the developers </div><div>don't know that. </div><div><br></div><div>In general, I think is good look at the activity.py code, to get ideas about </div>
<div>what problems can appear.</div><div><br></div><div>Gonzalo</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 16, 2013 at 11:04 AM, Walter Bender <span dir="ltr"><<a href="mailto:walter.bender@gmail.com" target="_blank">walter.bender@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Aug 16, 2013 at 8:01 AM, Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>> wrote:<br>

> This is one of the most important APIs we will have, so I would<br>
> like to open discussion on it.<br>
><br>
> In GTK activities, the activity developer subclass Activity, and<br>
> override read() and write() methods.<br>
><br>
> In web activities, we don't have that kind of hierarchy.  Instead, the<br>
> activity developer imports 'activity/activity' module, and calls<br>
> activity.setup() .  Then she/he can use activity.getDatastoreObject()<br>
> to read and write.<br>
><br>
> In GTK activities, 'read' is called at startup and 'write' is called<br>
> when the activity goes to the background or when it stops.  Recently,<br>
> I added in sugar-web those notifications, with the intention to make<br>
> web activities behave like GTK ones.<br>
><br>
> I provided an initial patch and dnarvaez proposed another option:<br>
> <a href="https://github.com/sugarlabs/sugar-web/pull/74" target="_blank">https://github.com/sugarlabs/sugar-web/pull/74</a><br>
><br>
> So we can:<br>
><br>
> - Let web developers connect to the 'pause' and 'stop' notifications,<br>
>   and use the activity datastore object directly. Pro: is more<br>
>   flexible.  Con: more work in the activity side: error handling,<br>
>   datastore object handling.<br>
><br>
> - Subscribe 'read' and 'write' functions in activity.setup() .  They<br>
>   will be called as expected, like in GTK.  'read' will have a JSON<br>
>   string as argument.  'write' must return a JSON string.  Pro:<br>
>   simpler approach.  Con: less flexibility in the activity side.  A<br>
>   mockup can be found in this comment:<br>
>   <a href="https://github.com/manuq/sugar-web/commit/3c2420f59c9aa8df44d2c0d639fe37b4af63f9fb#commitcomment-3872770" target="_blank">https://github.com/manuq/sugar-web/commit/3c2420f59c9aa8df44d2c0d639fe37b4af63f9fb#commitcomment-3872770</a><br>

><br>
> Thoughts?  Any other ideas?<br>
<br>
</div></div>Re read/write for JS, I think the solution has been sufficiently<br>
flexible for our Python activities. While I appreciate the flexibility<br>
of Not sure of connecting to pause and stop notifications, is there a<br>
use case where this is necessary or advantageous? Plus we need read in<br>
both scenarios.<br>
<div class="im HOEnZb"><br>
><br>
><br>
> --<br>
> .. manuq ..<br>
> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br>
<br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Walter Bender<br>
Sugar Labs<br>
<a href="http://www.sugarlabs.org" target="_blank">http://www.sugarlabs.org</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</div></div></blockquote></div><br></div>