ProtoRPC +AppEngine+Django

75 views
Skip to first unread message

Constantine Vasil

unread,
Jun 21, 2011, 12:51:54 PM6/21/11
to google-prot...@googlegroups.com
How to integrate ProtoRPC +AppEngine+Django?

Particularly Registering the service:

# Register mapping with application.

application = webapp.WSGIApplication(

 service_handlers.service_mapping(

     [('/postservice', postservice.PostService)]),

 debug=True)



def main():

 util.run_wsgi_app(application)


With Django and AppEngine:


def main():

# Create a Django application for WSGI.

    application = django.core.handlers.wsgi.WSGIHandler()


# Run the WSGI CGI handler with that application.

    util.run_wsgi_app(application)


if __name__ == '__main__':

    main()




if __name__ == '__main__':

 main()

Rafe Kaplan

unread,
Jun 21, 2011, 5:33:31 PM6/21/11
to google-prot...@googlegroups.com
For the time being I would say that the best way to have ProtoRPC
and Django share the same App Engine application is to put the
services in their own script. For example, consider the following
app.yaml:

handlers:

- url: /(protorpc|my_service|my_other_service).*
script: services.py # Contains ProtoRPC definitions

- url: .*
script: main.py # Contains Django handlers

We are looking to add the ability for ProtoRPC to be implemented as
a basic WSGI service, and in that case it will be easy to combine them
all in the same main file.

Constantine Vasil

unread,
Jun 21, 2011, 7:28:21 PM6/21/11
to google-prot...@googlegroups.com
great! I will try to make it work,

Estifanos Gebrehiwot

unread,
May 13, 2013, 5:24:33 PM5/13/13
to google-prot...@googlegroups.com

Hey , 
Can you post the relevant confs as well .. Here is what I was trying proto + django on HelloService

hello_service.py ...
     
  ---
    class HelloService(remote.Service):

    @remote.method(HelloRequest, HelloResponse)
    def hello(self, request):
        return HelloResponse(hello='Hello there, %s!' % request.my_name)

webapp.WSGIApplication(service_handlers.service_mapping([('/HelloService', HelloService)]),debug=True)
 
def app():
    application = django.core.handlers.wsgi.WSGIHandler()
    util.run_wsgi_app(application)


--- app.yaml

handlers:
- url: /HelloService.*

----


Testing from local 
  curl -H    'content-type:application/json'    -d '{"my_name": "Hello guestbook!"}'   http://localhost:8008/HelloService.hello

And I got nothing :(, 

Rafe Kaplan

unread,
May 13, 2013, 5:58:49 PM5/13/13
to google-prot...@googlegroups.com
For one, the webapp version of the handler is obsolete.  You should not be using it at all.  Instead use protorpc.wsgi.services.  From your configuration file I can see you are using Python 2.7.  The webapp version will not even work.

When you say you get nothing, what do you mean?  Does the server send a response?  Is there additional logging coming from the dev-appserver?


--
You received this message because you are subscribed to the Google Groups "ProtoRPC Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-protorpc-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
 - Rafe Kaplan
Reply all
Reply to author
Forward
0 new messages