[Sugar-devel] sugar-web - API for storing data

Gonzalo Odiard gonzalo at laptop.org
Fri Aug 16 10:55:36 EDT 2013


I am for a simple read/write solution,
add the following comments based in my experience with gtk activities.

* In gtk read is called in the map of the canvas. Is a little obscure
and can be a problem in some cases. By example, in activities where
you can start without a object and later select one with the object chooser.
Examples are Read and ImageViewer activities in the latest versions.
The problem was, adding a empty widget as a canvas triggered the read_file
method.
May be we can add a flag to disable the automatic call to read_file.

* Some activities assume a object is available to start the collaboration,
then should be needed start the collaboration after read_file.
Right now, max_participants need be set before the toolbar  creation,
and later changes do not enable/disable the collaboration button,
then a case like this should be managed by the programmer.

Should be good read this old bug http://bugs.sugarlabs.org/ticket/568
now we can start with a empty page.

I do not see problems with write_file. Activity class already have methods
like can_close() to enable validations if needed in the activity.

The gtk version show a very annoying alert when have a problem writing the
file,
I think is a good idea :) should be worst if we lost data and the
developers
don't know that.

In general, I think is good look at the activity.py code, to get ideas
about
what problems can appear.

Gonzalo




On Fri, Aug 16, 2013 at 11:04 AM, Walter Bender <walter.bender at gmail.com>wrote:

> On Fri, Aug 16, 2013 at 8:01 AM, Manuel Quiñones <manuq at laptop.org> wrote:
> > This is one of the most important APIs we will have, so I would
> > like to open discussion on it.
> >
> > In GTK activities, the activity developer subclass Activity, and
> > override read() and write() methods.
> >
> > In web activities, we don't have that kind of hierarchy.  Instead, the
> > activity developer imports 'activity/activity' module, and calls
> > activity.setup() .  Then she/he can use activity.getDatastoreObject()
> > to read and write.
> >
> > In GTK activities, 'read' is called at startup and 'write' is called
> > when the activity goes to the background or when it stops.  Recently,
> > I added in sugar-web those notifications, with the intention to make
> > web activities behave like GTK ones.
> >
> > I provided an initial patch and dnarvaez proposed another option:
> > https://github.com/sugarlabs/sugar-web/pull/74
> >
> > So we can:
> >
> > - Let web developers connect to the 'pause' and 'stop' notifications,
> >   and use the activity datastore object directly. Pro: is more
> >   flexible.  Con: more work in the activity side: error handling,
> >   datastore object handling.
> >
> > - Subscribe 'read' and 'write' functions in activity.setup() .  They
> >   will be called as expected, like in GTK.  'read' will have a JSON
> >   string as argument.  'write' must return a JSON string.  Pro:
> >   simpler approach.  Con: less flexibility in the activity side.  A
> >   mockup can be found in this comment:
> >
> https://github.com/manuq/sugar-web/commit/3c2420f59c9aa8df44d2c0d639fe37b4af63f9fb#commitcomment-3872770
> >
> > Thoughts?  Any other ideas?
>
> Re read/write for JS, I think the solution has been sufficiently
> flexible for our Python activities. While I appreciate the flexibility
> of Not sure of connecting to pause and stop notifications, is there a
> use case where this is necessary or advantageous? Plus we need read in
> both scenarios.
>
> >
> >
> > --
> > .. manuq ..
> > _______________________________________________
> > Sugar-devel mailing list
> > Sugar-devel at lists.sugarlabs.org
> > http://lists.sugarlabs.org/listinfo/sugar-devel
>
>
>
> --
> Walter Bender
> Sugar Labs
> http://www.sugarlabs.org
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20130816/80090410/attachment-0001.html>


More information about the Sugar-devel mailing list