Cloud World

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 15 April 2011

Introducing ProtoRPC for writing App Engine Web Services in Python

Posted on 11:52 by Unknown

Here on the App Engine team, we’re always looking for new ways to make it easier for developers to build applications and services. Today, I’m happy to introduce ProtoRPC, a new tool for creating simple Python services, which requires minimal set up and configuration to create new services.



What can you use ProtoRPC web-services for? Most web applications have the need to send and receive data between different components and/or applications. Typically, developers come up with ad-hoc ways of doing this as quickly as possible. As the application grows larger and the need to share information across components grows, it becomes more difficult to manage. URL end-points are defined and appear inconsistent from one another and a lot of boiler plate code is added checking parameters. This quickly becomes a maintenance nightmare and is a problem that ProtoRPC is built to solve.



ProtoRPC makes it easy to write consistent, reliable web interfaces that can be used, for example, to do the following:



  • Create AJAX URL end-points for use by dynamic web pages and forms.

  • Provide simple and understandable server-to-server communications.

  • Become a back-end for command-line tools or other non-web based clients.



Using ProtoRPC, you can define structured web-services right in the application’s Python code without having to first learn and write a new interface definition language such as Thrift and Protocol Buffers, however still retain the same powerful features such as interface introspection and automatic client generation.



The way to go about defining a web service should be familiar to you if you already have experience working with App Engine db.Models and the webapp framework. The data sent between client and web service are defined in a similar way as Datastore models. The services classes that handle requests are defined similarly to webapps RequestHandler classes. Let’s take a look at a simple example from the ProtoRPC getting started guide. This simple web service says hello to its client:




class HelloRequest(messages.Message):
my_name = messages.StringField(1, required=True)

class HelloResponse(messages.Message):
hello = messages.StringField(1, required=True)

class HelloService(remote.Service):

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


If this web services was used as the URL end-point for an AJAX based form, Javascript to communicate with the service might look like this:




$.ajax({url: ‘/helloservice.hello’,
type: 'POST',
contentType: 'application/json',
data: ‘{ my_name: Bob }’,
dataType: 'json',
success: function(response) {
// The response is { hello: “Hello there, Bob!” }
alert(response.hello);
}
});


As you can see from the example, ProtoRPC can speak JSON right out of the box. In addition, it is compatible with the protocol buffer binary format and can therefore communicate with clients and servers written using traditionally compiled .proto files.



Right now, ProtoRPC is available as an separate project that can be downloaded here. It’s still considered experimental and may change in substantial ways before being integrated in to the SDK. But even though it’s in preview, it already has a number of useful features, such as a remote service discovery mechanism and a forms interface for easy testing. At the moment, ProtoRPC is only available in Python. As always, we plan to offer it for Java developers in the near future.



Check out the getting started guide for a more complete overview to try out writing a few services of your own!



--

Rafe Kaplan, Software Engineer, App Engine Team
Email ThisBlogThis!Share to XShare to Facebook
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Bridging Mobile Backend as a Service to Enterprise Systems with Google App Engine and Kinvey
    The following post was contributed by Ivan Stoyanov , VP of Engineering for Kinvey, a mobile Backend as a Service provider and Google Cloud ...
  • Tutorial: Adding a cloud backend to your application with Android Studio
    Android Studio lets you easily add a cloud backend to your application, right from your IDE. A backend allows you to implement functionality...
  • 2013 Year in review: topping 100,000 requests-per-second
    2013 was a busy year for Google Cloud Platform. Watch this space: each day, a different Googler who works on Cloud Platform will be sharing ...
  • Easy Performance Profiling with Appstats
    Since App Engine debuted 2 years ago, we’ve written extensively about best practices for writing scalable apps on App Engine. We make writ...
  • TweetDeck and Google App Engine: A Match Made in the Cloud
    I'm Reza and work in London, UK for a startup called TweetDeck . Our vision is to develop the best tools to manage and filter real time ...
  • Scaling with the Kindle Fire
    Today’s blog post comes to us from Greg Bayer of Pulse , a popular news reading application for iPhone, iPad and Android devices. Pulse has ...
  • Who's at Google I/O: Mojo Helpdesk
    This post is part of Who's at Google I/O , a series of guest blog posts written by developers who are appearing in the Developer Sandbox...
  • A Day in the Cloud, new articles on scaling, and fresh open source projects for App Engine
    The latest release of Python SDK 1.2.3, which introduced the Task Queue API and integrated support for Django 1.0, may have received a lot ...
  • SendGrid gives App Engine developers a simple way of sending transactional email
    Today’s guest post is from Adam DuVander, Developer Communications Director at SendGrid. SendGrid is a cloud-based email service that deliv...
  • Qubole helps you run Hadoop on Google Compute Engine
    This guest post comes form Praveen Seluka, Software Engineer at Qubole, a leading provider of Hadoop-as-a-service.  Qubole is a leading pr...

Categories

  • 1.1.2
  • agile
  • android
  • Announcements
  • api
  • app engine
  • appengine
  • batch
  • bicycle
  • bigquery
  • canoe
  • casestudy
  • cloud
  • Cloud Datastore
  • cloud endpoints
  • cloud sql
  • cloud storage
  • cloud-storage
  • community
  • Compute Engine
  • conferences
  • customer
  • datastore
  • delete
  • developer days
  • developer-insights
  • devfests
  • django
  • email
  • entity group
  • events
  • getting started
  • google
  • googlenew
  • gps
  • green
  • Guest Blog
  • hadoop
  • html5
  • index
  • io2010
  • IO2013
  • java
  • kaazing
  • location
  • mapreduce
  • norex
  • open source
  • partner
  • payment
  • paypal
  • pipeline
  • put
  • python
  • rental
  • research project
  • solutions
  • support
  • sustainability
  • taskqueue
  • technical
  • toolkit
  • twilio
  • video
  • websockets
  • workflows

Blog Archive

  • ►  2013 (143)
    • ►  December (33)
    • ►  November (15)
    • ►  October (17)
    • ►  September (13)
    • ►  August (4)
    • ►  July (15)
    • ►  June (12)
    • ►  May (15)
    • ►  April (4)
    • ►  March (4)
    • ►  February (9)
    • ►  January (2)
  • ►  2012 (43)
    • ►  December (2)
    • ►  November (2)
    • ►  October (8)
    • ►  September (2)
    • ►  August (3)
    • ►  July (4)
    • ►  June (2)
    • ►  May (3)
    • ►  April (4)
    • ►  March (5)
    • ►  February (3)
    • ►  January (5)
  • ▼  2011 (46)
    • ►  December (3)
    • ►  November (4)
    • ►  October (4)
    • ►  September (5)
    • ►  August (3)
    • ►  July (4)
    • ►  June (3)
    • ►  May (8)
    • ▼  April (2)
      • Who's at Google I/O: Simperium
      • Introducing ProtoRPC for writing App Engine Web Se...
    • ►  March (5)
    • ►  February (3)
    • ►  January (2)
  • ►  2010 (38)
    • ►  December (2)
    • ►  October (2)
    • ►  September (1)
    • ►  August (5)
    • ►  July (5)
    • ►  June (6)
    • ►  May (3)
    • ►  April (5)
    • ►  March (5)
    • ►  February (2)
    • ►  January (2)
  • ►  2009 (47)
    • ►  December (4)
    • ►  November (3)
    • ►  October (6)
    • ►  September (5)
    • ►  August (3)
    • ►  July (3)
    • ►  June (4)
    • ►  May (3)
    • ►  April (5)
    • ►  March (3)
    • ►  February (7)
    • ►  January (1)
  • ►  2008 (46)
    • ►  December (4)
    • ►  November (3)
    • ►  October (10)
    • ►  September (5)
    • ►  August (6)
    • ►  July (4)
    • ►  June (2)
    • ►  May (5)
    • ►  April (7)
Powered by Blogger.

About Me

Unknown
View my complete profile