I'm sure I'm just not looking in the right place, but I can't seem to find any description of what the differences between the Global, Instance, and Person versions of Persistent data are. Can anyone explain what each one is?
Imagine you created a game app and would like to store data for it.
Global Data: This data is available on a large scale, that is, it is available to your application regardless of where it is placed. For instance, if Jane and Jill both place your game application on their profile, the global data set and retrieved will be exactly the same for both Jane and Jill's copy of the game. This could be useful for storing something like High Scores.
Instance Data: This data is available only to the specific copy (instance) of the game (app). So if Jane and Jill both place your game on their profile, the game will be able to store unique data. In this case, Jane's game cannot access Jill's game's unique data storage (instance Data) and likewise. An example use for this may be if a game requires the 'state' of the game to be saved or you would like to keep High Scores separated for each instance.
Person App Data: relates to a data store for an individual with relation to the app on a global scale. Meaning that both Jill and Jane's copy of the game will be able to access the same data for a Person, but other applications will not have access to your application's data for that person. The key here is that you're storing data under a person with relation to an app. So if you try to access that data for the same person from a different app, it won't exist. An example use would be 'High Scores for Jill' (or jane), or allowing users to save their game.
On Nov 10, 6:12 pm, Zach <zcox...@gmail.com> wrote:
> I'm sure I'm just not looking in the right place, but I can't seem to > find any description of what the differences between the Global, > Instance, and Person versions of Persistent data are. Can anyone > explain what each one is?
Dustin - thank you for the incredibly useful reply! I now understand the differences and this should help those in the future confused by the same things.
On Nov 13, 12:42 pm, "Dustin.Jo...@gmail.com" <Dustin.Jo...@gmail.com> wrote:
> Imagine you created a gameappand would like to storedatafor it.
> GlobalData: Thisdatais available on a large scale, that is, it is > available to your application regardless of where it is placed. Forinstance, if Jane and Jill both place your game application on their > profile, the globaldataset and retrieved will be exactly the same > for both Jane and Jill's copy of the game. This could be useful for > storing something like High Scores.
> InstanceData: Thisdatais available only to the specific copy > (instance) of the game (app). So if Jane and Jill both place your game > on their profile, the game will be able to store uniquedata. In this > case, Jane's game cannot access Jill's game's uniquedatastorage > (instanceData) and likewise. An example use for this may be if a game > requires the 'state' of the game to be saved or you would like to keep > High Scores separated for eachinstance.
> PersonAppData: relates to adatastore for an individual with > relation to theappon a global scale. Meaning that both Jill and > Jane's copy of the game will be able to access the samedatafor a > Person, but other applications will not have access to your > application'sdatafor that person. The key here is that you're > storingdataunder a person with relation to anapp. So if you try to > access thatdatafor the same person from a differentapp, it won't > exist. An example use would be 'High Scores for Jill' (or jane), or > allowing users to save their game.
> On Nov 10, 6:12 pm, Zach <zcox...@gmail.com> wrote:
> > I'm sure I'm just not looking in the right place, but I can't seem to > > find any description of what the differences between the Global, > >Instance, and Person versions of Persistentdataare. Can anyone > > explain what each one is?
What I'd like to know, though, is want the access restrictions are on personal and instance data. In the example of the game app. Would Jill and Jane be able to see each other's high scores (assuming that they were friends,) if it was personal, or would that data have to be global?
Another thing I noticed is that although there are methods in opensocial.DataRequest to update the instance and personal app data, but there isn't one for global. Is it to be assumed that this feature is going to be added?
I'm not the person to answer, but I also noticed the lack of update global app data. I'm curious as well.
I think for your first question, you can do that by retrieving person app data for OWNER_FRIENDS, so assuming you stored the high score jane, and jill and jane are friends, jill should be able to grab jane's high score. Correct me if I'm wrong.
aaron.cha...@gmail.com wrote: > What I'd like to know, though, is want the access restrictions are on > personal and instance data. In the example of the game app. Would Jill > and Jane be able to see each other's high scores (assuming that they > were friends,) if it was personal, or would that data have to be > global?
> Another thing I noticed is that although there are methods in > opensocial.DataRequest to update the instance and personal app data, > but there isn't one for global. Is it to be assumed that this feature > is going to be added?
From my testing, I've found that you are correct. You can access
person app data, if they are friends.
I am having a bit of difficulty actually parsing it, though. In my
handler, I get the specific key data (using data = response.get(key)),
and then get the data object (using theobject = data.getData()), but I
can't figure out how to actually get the string value that is stored
in theobject. I've looked through the docs, and just a normal search,
but I couldn't seem to find it. I know that it's returning the correct
data, because I've been checking the responses with Firebug, but still
no dice on actually using it. Any help would be appreciated. Thanks.
In testing, I verified that friends can indeed see each other's person
app data, so that's good. It would've been a little crazy having to
use global app data for everyone, I'm glad that provision was in
there.
I am having a bit of an issue with using the returned data, though. I
can verify using firebug that it's coming through, and that it's
correct, but I can't seem to figure out how to display it on the page.
In my handler function, I get the response item from the response data
(using data = response.get(key)), and pull the object out of the
response data (using theobject = data.getData()), but I can't get the
actual string value of theobject to display. If anyone could give me
some advice, I'd appreciate it.
> In testing, I verified that friends can indeed see each other's person
> appdata, so that's good. It would've been a little crazy having to
> use global appdatafor everyone, I'm glad that provision was in
> there.
> I am having a bit of an issue with using the returneddata, though. I
> can verify using firebug that it's coming through, and that it's
> correct, but I can't seem to figure out how to display it on the page.
> In my handler function, I get the response item from the responsedata
> (usingdata= response.get(key)), and pull the object out of the
> responsedata(using theobject =data.getData()), but I can't get the
> actual string value of theobject to display. If anyone could give me
> some advice, I'd appreciate it.
Well, I'm not sure this is the best way, but this is how I've been doing it since I haven't figured out how to iterate through the maps.
The data comes back as a map object per the spec (for newFetchPersonAppDataRequest) "When processed, returns a Map<PersonId <http://code.google.com/apis/opensocial/docs/javascript/reference/open...>>, Map<String, String>> object." So in your example you should be able to access the data by using data[personID]["dataKeyName"]. Like I said I haven't figured out how to iterate through these, so in order to grab the data for say "OWNER_FRIENDS" I first make sure I have a list of owner friends ( from newFetchPeopleRequest ) and then iterate through them and check to see if a corresponding value exists in my appdata object. So I would do something like this:
ownerFriends = ( get a list of friends using newFetchPeopleRequest then get("key").getData() ) data = ( as you described below, a returned object from newFetchPersonAppDataRequest )
ownerFriends.each( function(aPerson){ // note that each is a function of collection which is returned by newFetchPeopleRequest if( data[aPerson.getId()] != null ) { // do something with data... can be accessed using data[aPerson.getId()]["dataKey"] }
});
This works for me for now, but I'd be in anyone's debt who could explain map iteration.
aaron.cha...@gmail.com wrote: > In testing, I verified that friends can indeed see each other's person > app data, so that's good. It would've been a little crazy having to > use global app data for everyone, I'm glad that provision was in > there.
> I am having a bit of an issue with using the returned data, though. I > can verify using firebug that it's coming through, and that it's > correct, but I can't seem to figure out how to display it on the page. > In my handler function, I get the response item from the response data > (using data = response.get(key)), and pull the object out of the > response data (using theobject = data.getData()), but I can't get the > actual string value of theobject to display. If anyone could give me > some advice, I'd appreciate it.
That absolutely did the trick, thanks! I kept looking for a method,
instead of just using the index. D'oh.
From what I know of maps (which isn't a ton), since you can't just
iterate through them without a list of the keys, since the map itself
doesn't store anything other than the key-value pairings. They seem to
be very similar to Python's dictionaries (which I've worked a bit more
with), which leads me to beleive that there is a method that would
return the list of keys in the map. I've tried some of the obvious
possibilities (getKeys, keys, keyList, listKeys, etc), but no dice so
far.
Just for clarity I wanted to specify that in my example above, data is
an object returned by newFetchPersonAppDataRequest then
get("key").getData() rather than just get("key")... So
var data;
function handleRet(ret){
data = ret.get("key").getData() == null ? {} :
ret.get("key").getData();
}
On Nov 15, 10:42 am, "aaron.cha...@gmail.com" <aaron.cha...@gmail.com>
wrote:
> That absolutely did the trick, thanks! I kept looking for a method,
> instead of just using the index. D'oh.
> From what I know of maps (which isn't a ton), since you can't just
> iterate through them without a list of the keys, since the map itself
> doesn't store anything other than the key-value pairings. They seem to
> be very similar to Python's dictionaries (which I've worked a bit more
> with), which leads me to beleive that there is a method that would
> return the list of keys in the map. I've tried some of the obvious
> possibilities (getKeys, keys, keyList, listKeys, etc), but no dice so
> far.