No more application data in Open Social 0.7

0 views
Skip to first unread message

Jerome

unread,
Feb 11, 2008, 11:45:53 PM2/11/08
to Orkut Developer Forum
My Open Social app has been making extensive use of the
newFetchInstanceAppDataRequest() to store application settings which
have to be the same for all viewers (and which can be set by the owner
or the owner friends). I am now working on the port of my app to 0.7
and Open Social 0.7 release note says:

Simplified persistence API. Support for global and instance-scoped
application data has been removed from the API. Global application
data can be implemented using feeds (that can be prefetched for
performance) and other web standards. Instance-scoped application data
can be implemented on top of user-scoped data by including the module
ID of the application in the key.

I think this limitation leaves a gap for storing application data
which are not user centric, unless I am missing something in the
understanding of what 0.7 offers. For the discussion, consider the
sample app below, which implements a counter of views of a user
profile. The code as showed below will not work, as the viewer is not
allowed to update application data for the owner. If you substitude
all the owner by viewer in the code below, then this works as
expected, and the application counts the number of time the viewer has
ran this specific app.

What are the solution with 0.7 to store app instance data in the data
store, and not on an external system?

Thanks,

Jerome

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs
title="Profile view counter"
>
<Require feature="opensocial-0.7"/>
</ModulePrefs>
<Content type="html">
<![CDATA[

<script type="text/javascript">

_IG_RegisterOnloadHandler(init);

function init() {
var req = opensocial.newDataRequest();

req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER),
'owner');

req.add(req.newFetchPersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER,
'counter'), 'data');
req.send(onLoad);
};

function onLoad(data) {
var count = 0;
var dataArr = data.get('data').getData();
var owner = data.get('owner').getData();
count = dataArr[owner.getId()]['counter'];

document.getElementById('count').innerHTML = count;
count++;

var req = opensocial.newDataRequest();
// Following is not error out but does not have any effect as
AppDataRequest on non-viewer is not supported

req.add(req.newUpdatePersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER,
'counter', count));
req.send();
};

</script>

This gadget has been viewed <span id="count">(Counting...)</span>
times.

]]>
</Content>
</Module>
Reply all
Reply to author
Forward
0 new messages