Difference between revisions of "Data Persistence"

From Chumby Wiki
Jump to: navigation, search
(New page: There are two methods of saving state between rotations of a widget: * persisting to the Chumby servers * persisting locally. == Persisting to Chumby Servers == == Persisting Locally == ...)
 
Line 1: Line 1:
There are two methods of saving state between rotations of a widget:
+
Sometimes widgets take information from users that should be stored for later.  For instance, if a user changes the color of a screen by pressing an icon on the screen, then when the widget next loads it should still use this color.
* persisting to the Chumby servers
+
* persisting locally.
+
  
== Persisting to Chumby Servers ==
+
== Persisting to Chumby Servers: the Chumby API ==
 +
* persists across Chumby reboots
 +
* may take longer because of network fetches
  
== Persisting Locally ==
+
== Persisting Locally: Mobile Shared Objects ==
  
 
This involves using objects of the SharedObject class.
 
This involves using objects of the SharedObject class.
=== Limitations ===
+
* store in /tmp/pdata, but it is not easily readable
 +
* will not be available when a Chumby restarts.
 +
* flashplayer does not support shared objects, so this will have to be tested on the Chumby.
 +
 
 +
=== General Approach ===
 +
 
 
=== MTASC Issues ===
 
=== MTASC Issues ===
 +
MTASC has an older, incomplete definition for SharedObject.  The file SharedObject.as (on Linux stored in /usr/share/mtasc/std/SharedObject.as) will have to be edited to include the following code:
 +
 +
static function addListener(objectName:String, notifyFunction:Function): Void;
 +
static function removeListener(objectName:String): Void;
 +
 +
With this definition of SharedObject, it is not possible to have ''private data'' -- that is, data on the shared object that will not persist.  This is not a detriment, because in an object oriented project there will be other places to store private data.  Note that this makes it difficult to derive a new class from SharedObject.
 +
 
=== Debugging ===
 
=== Debugging ===

Revision as of 09:51, 16 March 2008

Sometimes widgets take information from users that should be stored for later. For instance, if a user changes the color of a screen by pressing an icon on the screen, then when the widget next loads it should still use this color.

Persisting to Chumby Servers: the Chumby API

  • persists across Chumby reboots
  • may take longer because of network fetches

Persisting Locally: Mobile Shared Objects

This involves using objects of the SharedObject class.

  • store in /tmp/pdata, but it is not easily readable
  • will not be available when a Chumby restarts.
  • flashplayer does not support shared objects, so this will have to be tested on the Chumby.

General Approach

MTASC Issues

MTASC has an older, incomplete definition for SharedObject. The file SharedObject.as (on Linux stored in /usr/share/mtasc/std/SharedObject.as) will have to be edited to include the following code:

static function addListener(objectName:String, notifyFunction:Function): Void;
static function removeListener(objectName:String): Void;

With this definition of SharedObject, it is not possible to have private data -- that is, data on the shared object that will not persist. This is not a detriment, because in an object oriented project there will be other places to store private data. Note that this makes it difficult to derive a new class from SharedObject.

Debugging