Python Development on
- Allows deployment of web applications on Google’s famously robust infrastructure.
- Google is a big Python shop - Python is the only language initially supported on AppEngine
- (“Wordle” Google AppEngine application).
• Data Store
• URL Fetch
App Engine APIs
- Data Store API offers persistent storage in a RDBMS-like environment
- Image API offers uploadable images and transformations such as resize, rotate, crop, ﬂip,
and the mysterious “I’m feeling lucky” transformation.
- Mail API offers email services.
- Memcache API offers use of the same memory caching technology used in production
- URL Fetch offers HTTP client services, allowing HTTP access to other web services.
- Users API offers integration with Google Accounts.
App Engine Basics
- We’re going to look brieﬂy at creating “Hello World” as an AppEngine app.
- First you need to download the development environment.
- Nice graphical tools available for Windows and OS X
- Command line tools otherwise available
- On OS X, the app launcher shows the apps you have available, providing tools to run them
locally and deploy them to Google.
- Ultimately this is icing over the command line tools that do the work:
dev_appserver.py is the development web server.
appcfg.py is the tool for uploading your app to Google.
- First you need to create an application at appengine.google.com.
- Currently you are limited to 3 applications, and you must live on the
- From there you can generate a new app. A basic AppEngine app contains three ﬁles at
1. “app.yaml” is a YAML ﬁle that identiﬁes basic information about the application, and maps
URL patterns to “handlers”.
2. “index.yaml” is a YAML ﬁle that is used in conjunction with queries to the Data Store
4. “main.py” is the starter “handler” code. It is referenced in “app.yaml”.
- speciﬁes meta-data about the application
- speciﬁes “handlers”, somewhat similar to how Apache maps url patterns to handlers.
- handlers are python ﬁles.
- handler classes subclass RequestHandler
- handler is registered by sending the handler class and the context path to a
- the WSGIApplication is passed to the wsgiref.handlers module (part of standard Python
(WSGI, the Web Server Gateway Interface, is the standard for Python web applications. It is
Django’s goal for 1.0 to be 100% WSGI compliant.)
- The Handler implements methods corresponding to HTTP methods. These methods are
called when an HTTP request comes in that matches the context path set in the
• dev_appserver.py django-nyc
• appcfg.py update django-nyc
- dev_appserver.py runs the development server for that app, analagous to manage.py
- appcfg.py will upload the latest version of the application to Google
- you must have created the app on the AppEngine console before doing this
The Django Helper
- Google has a project that allows people to adapt Django projects to Google AppEngine
- Allows for a higher level of abstraction than the vanilla AppEngine apps provide.
- google-app-engine-django provides a new app for you to copy into your project:
appengine_django. You need to add it to your INSTALLED_APPS.
- app.yaml is mostly the same.
- note that /static is routed to a static directory, and not to the python handler
- main.py is supplied by appengine_django. It uses a built in handler to act as the
RequestHandler - delegating to the Django framework.
- from here the request path becomes standard Django: the settings.py ﬁle speciﬁes the
main urls.py ﬁle, which in turn delegate to other urls.py ﬁles, or maps requests to views.
- Google doesn’t use a relational database system in the traditional sense.
- The appengine_django app provides an alternate ORM to the application than the standard
- The familiar Poll app, redone in AppEngine.
- Note that the *Property objects are analogous to Field classes in the Django ORM