Chris,

would you fix my todo example and email it back to me? I will repost
it.

I can also give access to the AlterEgo entry if you email me
personally.

Massimo

On Feb 8, 6:04 pm, chris p <[email protected]> wrote:
> Here's the reference I was using for the error return 
> protocol:http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html
>
> On Feb 8, 1:24 pm, mdipierro <[email protected]> wrote:
>
> > Thank you chris. I also just posted this:
>
> >http://groups.google.com/group/web2py/browse_thread/thread/96b5a94552...
>
> > On Feb 8, 11:35 am, chris p <[email protected]> wrote:
>
> > > I'm reposting as my first didn't seem to go through....
>
> > > I got this working with the pyjamas JSONRPCExample.  Most of the
> > > changes were in the jsonrpc server examples posted above. Here's the
> > > code
>
> > > ---------------- controllers/rpc.py ----------------------
> > > # try something like
> > > def index():
> > >     return jsonrpc.serve()
>
> > > @jsonrpc
> > > def echo(text):
> > >     return 'echoing: %s' % text
>
> > > @jsonrpc
> > > def reverse(text):
> > >     return text[-1::-1]
>
> > > @jsonrpc
> > > def uppercase(text):
> > >     return text.upper()
>
> > > @jsonrpc
> > > def lowercase(text):
> > >     return text.lower()
>
> > > ------------- models/jsonrpc.py -------------------------
> > > """
> > > original code from :http://trac.pyworks.org/pyjamas/wiki/DjangoWithPyJamas
> > > """
> > > import gluon.contrib.simplejson as simplejson
> > > import types
>
> > > class JSONRPCService:
> > >     def response(self, id, result):
> > >         return simplejson.dumps({'version': '1.1', 'id':id,
> > > 'result':result, 'error':None})
> > >     def error(self, id, code, message):
> > >         return simplejson.dumps({'id': id,
> > >                                  'version': '1.1',
> > >                                  'error': {'name': 'JSONRPCError',
> > >                                            'code': code,
> > >                                            'message': message
> > >                                            }
> > >                                      })
>
> > >     def __init__(self):
> > >         self.methods={}
>
> > >     def serve(self):
> > >         import sys
> > >         data = simplejson.loads(request.body.read())
> > >         id, method, params = data["id"], data["method"], data
> > > ["params"]
> > >         if method in self.methods:
> > >             try:
> > >                 result =self.methods[method](*params)
> > >                 return self.response(id, result)
> > >             except BaseException:
> > >                 etype, eval, etb = sys.exc_info()
> > >                 return self.error(id, 100, '%s: %s' %(etype.__name__,
> > > eval))
> > >             except:
> > >                 etype, eval, etb = sys.exc_info()
> > >                 return self.error(id, 100, 'Exception %s: %s' %(etype,
> > > eval))
> > >         else:
> > >             return self.error(id, 100, 'method "%s" does not exist' %
> > > method)
>
> > >     def __call__(self,func):
> > >         self.methods[func.__name__]=func
> > >         return func
>
> > >     def listmethods(self):
> > >         return self.methods.keys()
>
> > > jsonrpc=JSONRPCService()
>
> > > ---------------------------------------------------------------------------
> > >  --------------
>
> > > Then you need to change the server location in the pyjamas code  to
> > > something like this
>
> > > class EchoServicePython(JSONProxy):
> > >     def __init__(self):
> > >         JSONProxy.__init__(self, "/pyjamas_2/rpc", ["echo", "reverse",
> > > "uppercase", "lowercase"])
>
> > > where you would change "pyjamas_2" for your app name
>
> > > I put the "output" folder from the pyjamas build into the web2py
> > > static directory
>
> > > Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to