Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
JSON from robot (python) to gadget the right way
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Agustin Horischnik  
View profile  
 More options Oct 21, 11:56 am
From: Agustin Horischnik <agu...@gmail.com>
Date: Wed, 21 Oct 2009 08:56:13 -0700 (PDT)
Local: Wed, Oct 21 2009 11:56 am
Subject: JSON from robot (python) to gadget the right way
Hi, I have a python robot which updates the state of a gadget. What
would be the right way to pass a list/array to the gadget? I assume
it's encoding it in JSON, right? But what's the right way to do that?
I tried importing simplejson from Django but it didn't really work
very well.

Is anybody doing this kind of thing?

Thanks.
Agustin.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pamela (Google Employee)  
View profile  
 More options Oct 21, 12:02 pm
From: "pamela (Google Employee)" <pamela...@gmail.com>
Date: Thu, 22 Oct 2009 03:02:04 +1100
Local: Wed, Oct 21 2009 12:02 pm
Subject: Re: [Google Wave APIs] JSON from robot (python) to gadget the right way

Hi Agustin-
The "Row of 4" robot does that. Have you looked at it's code?
http://wave-samples-gallery.appspot.com/about_app?app_id=36022

- pamela

On Thu, Oct 22, 2009 at 2:56 AM, Agustin Horischnik <agu...@gmail.com>wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 21, 2:35 pm
From: Agustin Horischnik <agu...@gmail.com>
Date: Wed, 21 Oct 2009 11:35:57 -0700 (PDT)
Local: Wed, Oct 21 2009 2:35 pm
Subject: Re: JSON from robot (python) to gadget the right way
Hi Pamela, thanks for your answer.

I did look at Row of 4 code and I just double checked it but I think
it doesn't send anything more than strings or numbers as values within
the delta dictionary.

What I meant was something like this:

controls = document.Gadget('http://MYAPP.appspot.com/public/
controls.xml')
doc.AppendElement(controls)
delta = {}
foo = ['One', 'Two', 'Three']
delta['bar'] = foo
controls.SubmitDelta(delta)

I've tried this and an odd thing happens: the gadget doesn't get
appended to the blip but I see no errors in the log... The debug log
shows:

CONSTRUCTING gadget with:{'url': 'http://MYAPP.appspot.com/public/
controls.xml', 'foobar': ['One', 'Two', 'Three']}

Outgoing:
[...]
"              property":{
               "type":"GADGET",
               "properties":{
                  "javaClass":"java.util.HashMap",
                  "map":{
                     "url":"http://MYAPP.appspot.com/public/
controls.xml",
                     "foobar":{
                        "javaClass":"java.util.HashMap",
                        "map":{
                           "javaClass":"java.util.ArrayList",
                           "list":{
                              "javaClass":"java.util.ArrayList",
                              "list":[
                                 "One",
                                 "Two",
                                 "Three"
                              ]

[...]

Is using a list object as a value in a dictionary not supported when
sending delta?

Cheers.
Agustin.

On Oct 21, 6:02 pm, "pamela (Google Employee)" <pamela...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pamela (Google Employee)  
View profile  
 More options Oct 21, 8:08 pm
From: "pamela (Google Employee)" <pamela...@gmail.com>
Date: Thu, 22 Oct 2009 11:08:04 +1100
Local: Wed, Oct 21 2009 8:08 pm
Subject: Re: [Google Wave APIs] Re: JSON from robot (python) to gadget the right way

Ah, got it. What was your experiencing with using simplejson? You should be
able to serialize that object and pass it through the delta. We don't have a
demo of that, but think it should work.
You could also consider using more complex keys, like
viewerName-propertyName-subPropertyName, etc. That is a bit better in terms
of concurrency.

- pamela

On Thu, Oct 22, 2009 at 5:35 AM, Agustin Horischnik <agu...@gmail.com>wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 21, 8:56 pm
From: Agustin Horischnik <agu...@gmail.com>
Date: Wed, 21 Oct 2009 17:56:46 -0700 (PDT)
Local: Wed, Oct 21 2009 8:56 pm
Subject: Re: JSON from robot (python) to gadget the right way

> Ah, got it. What was your experiencing with using simplejson? You should be
> able to serialize that object and pass it through the delta. We don't have a
> demo of that, but think it should work.

I don't remember but I'll re-try simplejson and report back.

> You could also consider using more complex keys, like
> viewerName-propertyName-subPropertyName, etc. That is a bit better in terms
> of concurrency.

hmm... I'm not sure I get that... could you please give me an example
whenever you have the time?

Agustin.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pamela (Google Employee)  
View profile  
 More options Oct 21, 9:05 pm
From: "pamela (Google Employee)" <pamela...@gmail.com>
Date: Thu, 22 Oct 2009 12:05:49 +1100
Local: Wed, Oct 21 2009 9:05 pm
Subject: Re: [Google Wave APIs] Re: JSON from robot (python) to gadget the right way

For example, if you are storing the information about a shape that a
participant just drew:
You could do:
delta = {'pamela.fox': "{'color':'red','shape':'circle'}"}

Or, you could do:
delta = {'pamela.fox-color': 'red'}
delta = {'pamela.fox-shape': 'circle'}

It may seem less elegant, but it is better in terms of concurrency, as it
means that I can independently change different properties.

On Thu, Oct 22, 2009 at 11:56 AM, Agustin Horischnik <agu...@gmail.com>wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 21, 9:14 pm
From: Agustin Horischnik <agu...@gmail.com>
Date: Thu, 22 Oct 2009 03:14:48 +0200
Local: Wed, Oct 21 2009 9:14 pm
Subject: Re: [Google Wave APIs] Re: JSON from robot (python) to gadget the right way

Gotcha. Yeah, I can see why is better for concurrency.
Thanks for your help.

On Thu, Oct 22, 2009 at 3:05 AM, pamela (Google Employee) <


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 26, 7:17 am
From: Agustin Horischnik <agu...@gmail.com>
Date: Mon, 26 Oct 2009 04:17:38 -0700 (PDT)
Local: Mon, Oct 26 2009 7:17 am
Subject: Re: JSON from robot (python) to gadget the right way
Reporting back on serializing objects and submitting them as delta.

I tried again using simplejson and the result is what I described
earlier without explicitly encoding them: the gadget breaks (i.e. in
this case it doesn't get
appended to the blip) and yet I see no errors in the log.

Let me know if need more info.

Agustin.

On Oct 22, 2:14 am, Agustin Horischnik <agu...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy Jasin  
View profile  
 More options Oct 26, 11:06 am
From: Teddy Jasin <jasin.te...@gmail.com>
Date: Mon, 26 Oct 2009 08:06:09 -0700 (PDT)
Local: Mon, Oct 26 2009 11:06 am
Subject: Re: JSON from robot (python) to gadget the right way
Hi Agustin,

I think I'm also facing same issue with you.
in my case I'm sending data from the robot to the gadget also using
json, however my json data is arabic texts which is converted
unicode... so it become longer json strings.

the gadget will not show if the passed data is too long.
so I guess my json data is too big to be passed into the gadget.
anyone can help me in this?

On Oct 26, 7:17 pm, Agustin Horischnik <agu...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 26, 4:02 pm
From: Agustin Horischnik <agu...@gmail.com>
Date: Mon, 26 Oct 2009 21:02:05 +0100
Local: Mon, Oct 26 2009 4:02 pm
Subject: Re: [Google Wave APIs] Re: JSON from robot (python) to gadget the right way

Hi Teddy, can you paste a few lines from your outgoing json containing the
strings you think could be causing the problem and maybe the bit of code
you're using to submit the delta and encode it?

I ended up using Pamela's suggestion but I'll be happy to try your code and
see if I find something.

Agustin.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy Jasin  
View profile  
 More options Oct 26, 11:59 pm
From: Teddy Jasin <jasin.te...@gmail.com>
Date: Mon, 26 Oct 2009 20:59:16 -0700 (PDT)
Local: Mon, Oct 26 2009 11:59 pm
Subject: Re: JSON from robot (python) to gadget the right way
Hi agustin,

here's the sample of some json I send to the gadget:

delta = {'surahcontent': u'\u0628\u0650\u0633\u0652\u0645\u0650
\u0627\u0644\u0644\u0651\u064e\u0647\u0650
\u0627\u0644\u0631\u0651\u064e\u062d\u0652\u0645\u064e
\u0670\u0646\u0650 \u0627\u0644\u0631\u0651\u064e\u062d\u0650\u064a
\u0645\u0650 \ufd3f \u0661\ufd3e\u0627\u0644\u0652\u062d\u064e
\u0645\u0652\u062f\u064f \u0644\u0650\u0644\u0651\u064e\u0647\u0650
\u0631\u064e\u0628\u0651\u0650 \u0627\u0644\u0652\u0639\u064e
\u0627\u0644\u064e\u0645\u0650\u064a\u0646\u064e \ufd3f \u0662\ufd3e',
'surahtitle': u'Al-Faatiha - The Opening (1-2)', 'translations':
u' (1) In the name of Allah, Most Gracious, Most Merciful.\n (2)
Praise be to Allah, the Cherisher and Sustainer of the worlds;\n'}

gadget.SubmitDelta(delta)

as u see the JSON I sending containing a long unicode strings, the
json above can successfuly show the gadget and show the content.
However when the delta above gets extremely long then it won't show
the gadget though no error in log file...

So I believe there's limit in the length of the delta that you can
send to gadget.

Teddy

On Oct 27, 4:02 am, Agustin Horischnik <agu...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Agustin Horischnik  
View profile  
 More options Oct 27, 6:31 am
From: Agustin Horischnik <agu...@gmail.com>
Date: Tue, 27 Oct 2009 03:31:32 -0700 (PDT)
Local: Tues, Oct 27 2009 6:31 am
Subject: Re: JSON from robot (python) to gadget the right way
I'm not sure about the length. There's something about that in this
thread:
http://groups.google.com/group/google-wave-api/browse_thread/thread/8...

But I can tell you that I tried sending a string of 200000 '1's and it
didn't break the gadget. And it's not getting chopped (i.e. on the
gadget, it's javascript length property equals 200000).

You can try this yourself:

cont = ''
for i in range(200000):
    cont += '1'

delta['cont'] = cont
gadget.SubmitDelta(delta)

What I did find playing with your code is this:

When I do:

delta = {}
delta['surahcontent'] = u'\u0628\u0644\u0651\u064e
\u0647\u0650\u0627\u0644\u0631\u0651\u064e\u062d\u0652\u0645\u064e'
gadget.SubmitDelta(delta)

I get no gadget and no error.

But if I encode the unicode string like so:
delta = {}
delta['surahcontent'] = u'\u0628\u0644\u0651\u064e
\u0647\u0650\u0627\u0644\u0631\u0651\u064e\u062d
\u0652\u0645\u064e'.encode('utf-8')
gadget.SubmitDelta(delta)

I get the gadget and the arabic caracters.

So I think what breaks the gadget is passing any thing other than a
string... If for instance I do:

delta['surahcontent'] = 1

it will fail. While doing:

delta['surahcontent'] = str(1)

will work.

Agustin.

On Oct 27, 4:59 am, Teddy Jasin <jasin.te...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy Jasin  
View profile  
 More options Oct 29, 12:50 am
From: Teddy Jasin <jasin.te...@gmail.com>
Date: Wed, 28 Oct 2009 21:50:24 -0700 (PDT)
Local: Thurs, Oct 29 2009 12:50 am
Subject: Re: JSON from robot (python) to gadget the right way
hemm thanks agustin...
thats interesting, I havent tried that...

I do my work around of not passing big data to gadget by just
providing necessary data, the gadget then do an AJAX based on the data
passed by the robot and display it...
its seems faster this way... the gadget displayed faster and I don't
get HIGH CPU warning on my log...

On Oct 27, 6:31 pm, Agustin Horischnik <agu...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
BI Guy  
View profile  
 More options Oct 29, 7:55 am
From: BI Guy <rao.polise...@fiserv.com>
Date: Thu, 29 Oct 2009 04:55:19 -0700 (PDT)
Local: Thurs, Oct 29 2009 7:55 am
Subject: Re: JSON from robot (python) to gadget the right way
I am trying to send some json data through JAVA Gadget.setField() and
sees the same issues with passing data. My experiments show that if
the string includes an embeded double quote(\") then it will pass the
value up to that character in string.

I believe, there is nothing wrong in embedding double quotes in a
string as they would be escaped anyway. Gadget.setField() is just
stopping as soon as it sees the double quote even if it is escaped.

This definitely should be fixed.

On Oct 29, 12:50 am, Teddy Jasin <jasin.te...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google