I am not sure of that, but perhaps this method should be included in the
docs as a way to test json-rpc.  The example in the book is a bit too
specific for what I want to do.  This way I can setup the service, verify
that it works, and move on to the next phase of development without setting
up pyjamas.

On Thu, Oct 22, 2009 at 11:37 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:

>
> should we include jsonrpclib in contrib?
>
> Massimo
>
> On Oct 22, 1:51 pm, Don Lee <sam...@gmail.com> wrote:
> > I made some progress.  Using jsonrpclib I am able to do the following.
> >
> > ===============================>>> import jsonrpclib
> > >>> s = jsonrpclib.ServerProxy("
> >
> > http://server.com/app/controller/call/jsonrpc";, verbose=1)
> >
> > >>> print s.echo("hello")
> >
> > send: 'POST /app/controller/call/jsonrpc HTTP/1.0\r\nHost:
> > server.com\r\nUser-Agent:
> > jsonlib.py/0.0.1 (by matt harrison)\r\nContent-Type:
> > text/xml\r\nContent-Length: 48\r\n\r\n'
> > send: '{"params": ["hello"], "method": "echo", "id": 6}'
> > reply: 'HTTP/1.1 500 INTERNAL SERVER ERROR\r\n'
> > header: Date: Thu, 22 Oct 2009 18:41:40 GMT
> > header: Server: Apache/2.2.3 (Red Hat)
> > header: web2py_error: ticket
> > app/IP.2009-10-22.14-41-40.33355e10-3005-407c-afb0-10e234a9edc4
> > header: Connection: close
> > header: Content-Type: text/html; charset=UTF-8
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> >   File "jsonrpclib.py", line 136, in __call__
> >     return self.__send(self.__name, args)
> >   File "jsonrpclib.py", line 382, in __request
> >     verbose=self.__verbose
> >   File "jsonrpclib.py", line 179, in request
> >     response
> > jsonrpclib.ProtocolError: <ProtocolError for
> > server.com/app/controller/call/jsonrpc: 500 INTERNAL SERVER ERROR>
> > ======================================
> >
> > That generated a ticket
> >
> > =======================================
> >
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 176, in restricted
> >     ccode = compile(code.replace('\r\n', '\n'), layer, 'exec')
> >   File "/web2py/applications/app/controllers/controller.py", line 45
> >     def echo(msg)
> >
> > ^
> > SyntaxError: invalid syntax
> >
> > ==================================
> >
> > I was missing a ":" in my function definition.  The point is, I can now
> test
> > from the CLI !  That should help debugging. I I had waited a couple of
> > minutes,  I could have saved an e-mail, but hopefully others will find
> this
> > useful.
> >
> > On Thu, Oct 22, 2009 at 2:30 PM, mdipierro <mdipie...@cs.depaul.edu>
> wrote:
> >
> > > Ignore my previous message.
> >
> > > I do not know. It is an RPC so the url is
> >
> > >http://127.0.0.1:8000/app/default/call/jsonrpc
> >
> > > but the request for "echo" has to be in the proper formatted jsonrpc
> > > protocol and I would not know how to build that from the shell.
> >
> > > On Oct 22, 12:54 pm, Don Lee <sam...@gmail.com> wrote:
> > > > I have created a test application to play around with json-rpc.
> >
> > > > =================================================
> > > > # coding: utf8
> >
> > > > def index():
> > > >     return dict()
> >
> > > > def call():
> > > >     return service
> >
> > > > @service.jsonrpc
> > > > def echo(msg)
> > > >     return msg
> > > > =================================================
> >
> > > > How can I test this service from the python shell?
> >
>

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

Reply via email to