opensocial.DataRequest.PersonId.OWNER

3 views
Skip to first unread message

Markitecht

unread,
Feb 13, 2008, 11:35:03 AM2/13/08
to Orkut Developer Forum
Instead of saving/displaying the data of the VIEWER of the
applications, my goal is for the OWNER of the app to take a quiz,
store the result, and display it on the profile view.

I am getting an error when trying to modify the tutorial code and
instead of 'opensocial.DataRequest.PersonId.VIEWER' use
'opensocial.DataRequest.PersonId.OWNER'

Any ideas? Is this just not yet implemented but the approach will be
successful in the future? Did I misunderstand the JS API spec?

thanks in advance everyone.

Christopher (markitecht/CODonnell)

Arne Roomann-Kurrik

unread,
Feb 13, 2008, 1:12:36 PM2/13/08
to opensoci...@googlegroups.com
Hi Chris,

   That's correct - we actually expect most sophisticated applications to work chiefly with retrieving OWNER and OWNER_FRIENDS data in order to allow user to present applications customized to their own profile.  However, you cannot just find/replace VIEWER with OWNER to make an application work this way - you will only be able to write to VIEWER app data, for example.

   The approach I've used is to check to see whether VIEWER == OWNER when rendering the gadget.  If true, then I give extra UI to allow customization of the application.  In your case, when the viewer is the owner, you would want to present the quiz questions, or possibly a button to take another quiz, storing all the results in VIEWER data.  In the case where the viewer is not the owner, then you would only want to render the OWNER's quiz results.

Hope this helps,
~Arne

Markitecht

unread,
Feb 13, 2008, 2:43:31 PM2/13/08
to Orkut Developer Forum
Mmmm yes.

Makes sense I think.

- App can only write VIEWER data, but can access OWNER data

- Exposing UI for editing app data only to OWNER, then using functions
storing VIEWER data (because you know it's the owner who is the
viewer) is a successful approach

- All app has to do then is always pull OWNER data to display.

lovely. thanks as always.

-Christopher


On Feb 13, 1:12 pm, "Arne Roomann-Kurrik" <api.kur...@google.com>
wrote:
> Hi Chris,
>
> That's correct - we actually expect most sophisticated applications to
> work chiefly with retrieving OWNER and OWNER_FRIENDS data in order to allow
> user to present applications customized to their own profile. However, you
> cannot just find/replace VIEWER with OWNER to make an application work this
> way - you will only be able to write to VIEWER app data, for example.
>
> The approach I've used is to check to see whether VIEWER == OWNER when
> rendering the gadget. If true, then I give extra UI to allow customization
> of the application. In your case, when the viewer is the owner, you would
> want to present the quiz questions, or possibly a button to take another
> quiz, storing all the results in VIEWER data. In the case where the viewer
> is not the owner, then you would only want to render the OWNER's quiz
> results.
>
> Hope this helps,
> ~Arne
>

A. Chapin

unread,
Feb 13, 2008, 3:05:40 PM2/13/08
to Orkut Developer Forum
Is there any way to update owner data if the viewer is not the owner?
I'd like to have the viewers of a person's profile be able to interact
with their app, and have the resulting data saved with the owner.

Jerome

unread,
Feb 13, 2008, 3:25:02 PM2/13/08
to Orkut Developer Forum
I had a similar question posted here:
http://groups.google.com/group/opensocial-orkut/browse_thread/thread/b08d6eae0e4bd54f#

From what I understand, this is not possible in 0.7. With previous
version, we had app instance data which were providing the storage for
such scenario.

This is not a blocking point for me, but I can see cases (like the
example in my previous post) where having owner data writable by
everybody would be very handy.

Jerome

Arne Roomann-Kurrik

unread,
Feb 13, 2008, 3:53:40 PM2/13/08
to opensoci...@googlegroups.com
The trouble with this approach is that it leaves the owner's data vulnerable to a malicious gadget, which could write anything it wanted into the owner's data fields.

I'll give you a hypothetical "leave comments" app to show you how I've been structuring my applications to work around this.  Imagine an application where the owner installs the app to their profile and sets a text field on the application as a welcome message to display to viewers.  Viewers of the app should be able to comment on the message (sort of a "wall" or "scraps" application).

First I'd check for cases where OWNER==VIEWER (the owner of the app is looking at the app on their profile).  If true:
   * Display an edit box so the owner can change the message to their friends
   * Save all data to the VIEWER (who is the owner in this case).

Second, I'd check to see if VIEWER is in OWNER_FRIENDS (viewer is friends with the owner).  If true:
   * Display a box where they can add a comment
   * Save the comment, a timestamp, and the owner's ID to the VIEWER's (who is the owner's friend) data store.

If neither case is true:
   * Display a message to the user where the comment box would be:  "Sorry, only friends of <name> can comment on this application.  Why not add <name> as a friend?"

Then to render the application:
   * Pull the OWNER's data to get the text to display as the top message
   * Pull the OWNER_FRIENDS' data to get a list of each friend's comments, timestamps, and the id of the profile that they commented on
   * If the id stored in a person's comment matches the current owner's id, the comment was made on this profile. 
   * Push all comments made on the current profile into an array and sort it based on the timestamps of each comment.
   * Display the resulting sorted array.

Hope that helps,
~Arne




 is that I've been putting in another check to see if the VIEWER is included in OWNER_FRIENDS.  If this is true, then I expo

A. Chapin

unread,
Feb 13, 2008, 4:40:35 PM2/13/08
to Orkut Developer Forum
I was thinking about doing something like that, but it's definitely
the "long way around/" Do you know why instance data was removed? I
think that it would definitely be handy in these sorts of situations.

Also, I understand the security risk, but if the potential size for
stored data is limited, what's the worst that could happen? Sure, an
app could post inappropriate things to a user's data, but that's the
case with the workaround as well.

Oh well, I'll just have to rework my app, for now.

pacheco

unread,
Mar 4, 2008, 6:04:10 PM3/4/08
to Orkut Developer Forum
Hi Arne,

The approach you described to this issue is really good. Only drawback
i see is that the owner would not be able to delete any comments or
messages showing at his application.

Or maybe we could store messages ID's (user_id + comment timestamp) of
"blocked" messages and then ignore those...

Anyway i'm a bit puzzled about DataAPI's storing limits...

Will we have some way to know how much space is left from those 10K
that are available? Or maybe will receive some kind of error message
when this limit is reached?

I realize that there is a request about raising up this limit here:
http://code.google.com/p/opensocial-resources/issues/detail?id=19

But those questions are important to anyone who is designing an app
and could lead to some major architectural changes.
For instance, maybe it would be better to store comments and things
like that in a external server.

tks in advance
--
Pacheco


On Feb 13, 5:53 pm, "Arne Roomann-Kurrik" <api.kur...@google.com>
wrote:
> On Feb 13, 2008 12:25 PM, Jerome <jerome.mou...@gmail.com> wrote:
>
>
>
> > I had a similar question posted here:
>
> >http://groups.google.com/group/opensocial-orkut/browse_thread/thread/...

JevS

unread,
Mar 4, 2008, 6:57:35 PM3/4/08
to Orkut Developer Forum
Hi Pacheco,

In theory there is possibilty to know how much space is left for a
viewer, by retreiving info for all used keys.
In my post http://webwidgets.ning.com/forum/topic/show?id=1472141%3ATopic%3A3922
I am showing how to get all such keys and to delete all records. The
key idea is to use
request.add(request.newFetchPersonAppDataRequest("VIEWER",
"*"),"somethinghere") to get all data per viewer with one request.
Certainly it would be more convenient to have some function from
Google. Also still not known what kind of error will occur when the
limit will be exceeded.
Cheers.
Jevs.

pacheco

unread,
Mar 4, 2008, 9:24:33 PM3/4/08
to Orkut Developer Forum
hi JevS, tks for point it out for me...

In theory i could calculate how much space is left... it's clearly not
the best way to get it but it is a possibility anyway.

Tks!
--
Pacheco


On 4 mar, 20:57, JevS <jevgenijs1...@gmail.com> wrote:
> Hi Pacheco,
>
> In theory there is possibilty to know how much space is left for a
> viewer, by retreiving info for all used keys.
> In my posthttp://webwidgets.ning.com/forum/topic/show?id=1472141%3ATopic%3A3922
Reply all
Reply to author
Forward
0 new messages