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

Manuel Quiñones manuq at laptop.org
Fri Aug 16 08:01:06 EDT 2013


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?


-- 
.. manuq ..


More information about the Sugar-devel mailing list