Google App Engine Blog

News, notes, tips and tricks from the Google App Engine Team

Friday, April 15, 2011

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:

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!

Great Rafe, thanks! What's the best way to send you any feedback? The google-appengine-python group perhaps or you created a dedicated one? I have just tried making the first example in your documentation work and I am already getting strange mistakes. Looking forward to see your library develop further and become part of the SDK!

If you are interested in providing feedback, I am very interested in hearing it and helping out where I can. I just created a discussion group for ProtoRPC. I will also try to keep up on the App Engine group.