[Google Wave APIs] Re: import json error with python-written robot

2009-11-07 Thread Niall

I realised my code was fine so that it was probably a problem with
globals, and found out that you can't use them here, or at least that
they can't be modified.
So I used the datastore, and it works now, which is nice.

Working solution can be found on the links I provided above.

On Nov 7, 2:15 pm, Niall twom...@gmail.com wrote:
 Thanks for your reply, Lee. I've been working on and off over the last
 couple of days and I think I'm stuck.

 The code I'm using can be found here 
 --http://code.google.com/p/googlewaverobots/source/browse/trunk/robotte...
 and the gadget is found 
 herehttp://code.google.com/p/googlewaverobots/source/browse/trunk/robotte...

 (I decided to try to replicate the translation robot, as it seemed
 like it'd teach me a good amount about python and the APIs)

 Anyway, the problem I'm having is that I can't get the robot, when a
 new blip is submitted, to read the state of the gadget, but when I
 modify the languages in the dropdown options it gets them fine. I
 think the problem is in how I search for the gadget, as when I modify
 the state of the gadget it works well, but if I don't it doesn't find
 the gadget.

 I searched the groups and can't find a way of doing this that works
 for me. I tried making global variables so that when the gadget is
 modified the language pairs would likewise be modified. I made two
 variables fr and to (language from which and to which we're
 translating) and in the onBlipSubmitted I did a global fr and global
 to and tried modifying them in the gadget key, elem gadget loop but to
 no avail -- I got no errors, but it wouldn't modify the values for me.
 You can also see what I've tried on the previous revisions of the
 code. If I set a default value for the global variables I can't change
 it, and if I don't set anything it says that the global name is not
 defined.

 Any help is very much appreciated.

 Cheers.

 On Nov 5, 12:52 am, Lee leeyuan...@gmail.com wrote:



  Looking at the API, the following python object will allow you to
  create a local UI on the client browser

  waveapi.document.Gadget(resource)

  And

  blip.GetDocument().AppendElement(Element*)

  Subclassed instances of Element are also allowed, so you can initiate
  a document.Gadget object

  The wave environment already provides an interface for the host
  application (more info 
  athttp://code.google.com/apis/wave/extensions/gadgets/guide.html),
  the following might help

  The gadget will contain a list that automatically invokes wave.getState
  ().submitDelta(dict); everytime the change event occurs on the list
  (you can do this via jQuery) and the result is sent back to the
  application, which does what it needs off of the information.

  On 4 Nov, 17:14, Niall twom...@gmail.com wrote:

   Thanks for your reply, Lee.
   I don't think the code for aunt-rosie is available (aunt-
   ro...@appspot.com to use it, and the developer's website is 
   herehttp://andrewhitchcock.org/?post=322)

   I think I know what I have to do, though. I was looking at the row of
   four source code, so I think I have to make a bit of a module like
   what it's got herehttp://rowoffour.appspot.com/gadget.xml
   I'll go play around with this for a while and report back with
   successes and failures.

   On Nov 4, 10:39 pm, Lee leeyuan...@gmail.com wrote:

The beauty of API design, and this is especially true of Google
projects, is that the binding exposes the same sets of methods and
objects for every language that it supports, so in theory it should be
relatively easy to port specific portions of the app across different
languages (all you need is a the most rudimentary amount of knowledge
about the syntax of Java).

If you can provide the link to download for the aunt-rosie robot, I
can help you locate and port the code to python. (Although it may be
in the API document, make sure that you check there first).

On 4 Nov, 08:42, Niall twom...@gmail.com wrote:
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-04 Thread Niall

Cheers.
I got it working before I saw the solutions ye posted. I went to
http://pypi.python.org/pypi/simplejson/2.0.9 and downloaded simplejson
and uploaded it with the robot I'm using. I might try to use Holger's
solution, though.
Thanks.

Now, my robot works does basically what it should do, but I'd like to
make it confugurable and I think the best way to do that would be to
allow whover's using the robot to select options from a dropdown menu
(from a blip that the robot posts when it is added to a wave). I've
seen this from a few different robots, but I'm not sure how it was
done. I've seen it on a few robots (aunt-rosie, for example, but
that's written in Java) so I figure it might be possible with python.
I searched, as i said. But couldn't see much that looked useful.

Cheers.

On Nov 3, 9:57 pm, Lee leeyuan...@gmail.com wrote:
 On Nov 3, 2:19 pm, Niall twom...@gmail.com wrote:



  Hi,

  I am currently writing a google wave robot for kicks, and I get the
  following error:

  type 'exceptions.ImportError': No module named json
  Traceback (most recent call last):
    File /base/data/home/apps/myWaveRobot/1.337487432489076904/
  myWaveRobot.py, line 14, in module
      import myWaveRobotModule
    File /base/data/home/apps/myWaveRobot/1.337487432489076904/
  myWaveRobotModule.py, line 3, in module
      import json

  And line three of myWaveRobotModule.py is --

  import json

  I did some searching and I can't figure out why I'm getting that error
  and couldn't see anything that seemed to match my problems. The error
  is printed like 19 times in the appenging main logs, but I don't know
  if that's important.

  Can anyone tell me why json doesn't work?

  Thanks. Let me know if you need any more information.

 Hi, the JSON library within python is native only for version 2.6.x
 and up, try the following

 easy_install simplejson - Make sure that you have installed ez_setup

 and within myWaveRobotModule.py, replace import json with import
 simplejson

 The two libraries' methods use the same method names and the same set
 of parameters so there shouldn't be any compatibility issue.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-04 Thread Lee

The beauty of API design, and this is especially true of Google
projects, is that the binding exposes the same sets of methods and
objects for every language that it supports, so in theory it should be
relatively easy to port specific portions of the app across different
languages (all you need is a the most rudimentary amount of knowledge
about the syntax of Java).

If you can provide the link to download for the aunt-rosie robot, I
can help you locate and port the code to python. (Although it may be
in the API document, make sure that you check there first).

On 4 Nov, 08:42, Niall twom...@gmail.com wrote:
 Cheers.
 I got it working before I saw the solutions ye posted. I went 
 tohttp://pypi.python.org/pypi/simplejson/2.0.9and downloaded simplejson
 and uploaded it with the robot I'm using. I might try to use Holger's
 solution, though.
 Thanks.

 Now, my robot works does basically what it should do, but I'd like to
 make it confugurable and I think the best way to do that would be to
 allow whover's using the robot to select options from a dropdown menu
 (from a blip that the robot posts when it is added to a wave). I've
 seen this from a few different robots, but I'm not sure how it was
 done. I've seen it on a few robots (aunt-rosie, for example, but
 that's written in Java) so I figure it might be possible with python.
 I searched, as i said. But couldn't see much that looked useful.

 Cheers.

 On Nov 3, 9:57 pm, Lee leeyuan...@gmail.com wrote:



  On Nov 3, 2:19 pm, Niall twom...@gmail.com wrote:

   Hi,

   I am currently writing a google wave robot for kicks, and I get the
   following error:

   type 'exceptions.ImportError': No module named json
   Traceback (most recent call last):
     File /base/data/home/apps/myWaveRobot/1.337487432489076904/
   myWaveRobot.py, line 14, in module
       import myWaveRobotModule
     File /base/data/home/apps/myWaveRobot/1.337487432489076904/
   myWaveRobotModule.py, line 3, in module
       import json

   And line three of myWaveRobotModule.py is --

   import json

   I did some searching and I can't figure out why I'm getting that error
   and couldn't see anything that seemed to match my problems. The error
   is printed like 19 times in the appenging main logs, but I don't know
   if that's important.

   Can anyone tell me why json doesn't work?

   Thanks. Let me know if you need any more information.

  Hi, the JSON library within python is native only for version 2.6.x
  and up, try the following

  easy_install simplejson - Make sure that you have installed ez_setup

  and within myWaveRobotModule.py, replace import json with import
  simplejson

  The two libraries' methods use the same method names and the same set
  of parameters so there shouldn't be any compatibility issue.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-04 Thread Niall

Thanks for your reply, Lee.
I don't think the code for aunt-rosie is available (aunt-
ro...@appspot.com to use it, and the developer's website is here
http://andrewhitchcock.org/?post=322)

I think I know what I have to do, though. I was looking at the row of
four source code, so I think I have to make a bit of a module like
what it's got here http://rowoffour.appspot.com/gadget.xml
I'll go play around with this for a while and report back with
successes and failures.


On Nov 4, 10:39 pm, Lee leeyuan...@gmail.com wrote:
 The beauty of API design, and this is especially true of Google
 projects, is that the binding exposes the same sets of methods and
 objects for every language that it supports, so in theory it should be
 relatively easy to port specific portions of the app across different
 languages (all you need is a the most rudimentary amount of knowledge
 about the syntax of Java).

 If you can provide the link to download for the aunt-rosie robot, I
 can help you locate and port the code to python. (Although it may be
 in the API document, make sure that you check there first).

 On 4 Nov, 08:42, Niall twom...@gmail.com wrote:


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-03 Thread Niall

OK. I figured it out. I did a version check on python on wave and got:

2.5.2 (r252:60911, Apr 7 2009, 17:42:26)
[GCC 4.1.0]

And if I remember right json came in with 2.6.



On Nov 3, 8:19 pm, Niall twom...@gmail.com wrote:
 Hi,

 I am currently writing a google wave robot for kicks, and I get the
 following error:

 type 'exceptions.ImportError': No module named json
 Traceback (most recent call last):
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobot.py, line 14, in module
     import myWaveRobotModule
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobotModule.py, line 3, in module
     import json

 And line three of myWaveRobotModule.py is --

 import json

 I did some searching and I can't figure out why I'm getting that error
 and couldn't see anything that seemed to match my problems. The error
 is printed like 19 times in the appenging main logs, but I don't know
 if that's important.

 Can anyone tell me why json doesn't work?

 Thanks. Let me know if you need any more information.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-03 Thread Lee

On Nov 3, 2:19 pm, Niall twom...@gmail.com wrote:
 Hi,

 I am currently writing a google wave robot for kicks, and I get the
 following error:

 type 'exceptions.ImportError': No module named json
 Traceback (most recent call last):
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobot.py, line 14, in module
     import myWaveRobotModule
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobotModule.py, line 3, in module
     import json

 And line three of myWaveRobotModule.py is --

 import json

 I did some searching and I can't figure out why I'm getting that error
 and couldn't see anything that seemed to match my problems. The error
 is printed like 19 times in the appenging main logs, but I don't know
 if that's important.

 Can anyone tell me why json doesn't work?

 Thanks. Let me know if you need any more information.

Hi, the JSON library within python is native only for version 2.6.x
and up, try the following

easy_install simplejson - Make sure that you have installed ez_setup

and within myWaveRobotModule.py, replace import json with import
simplejson

The two libraries' methods use the same method names and the same set
of parameters so there shouldn't be any compatibility issue.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---



[Google Wave APIs] Re: import json error with python-written robot

2009-11-03 Thread Holger

try this:

from django.utils import simplejson as json

had the same problem

On Nov 3, 9:19 pm, Niall twom...@gmail.com wrote:
 Hi,

 I am currently writing a google wave robot for kicks, and I get the
 following error:

 type 'exceptions.ImportError': No module named json
 Traceback (most recent call last):
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobot.py, line 14, in module
     import myWaveRobotModule
   File /base/data/home/apps/myWaveRobot/1.337487432489076904/
 myWaveRobotModule.py, line 3, in module
     import json

 And line three of myWaveRobotModule.py is --

 import json

 I did some searching and I can't figure out why I'm getting that error
 and couldn't see anything that seemed to match my problems. The error
 is printed like 19 times in the appenging main logs, but I don't know
 if that's important.

 Can anyone tell me why json doesn't work?

 Thanks. Let me know if you need any more information.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Wave API group.
To post to this group, send email to google-wave-api@googlegroups.com
To unsubscribe from this group, send email to 
google-wave-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-wave-api?hl=en
-~--~~~~--~~--~--~---