Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Google App Engine Development Shell
#!/usr/bin/env python -i
A local interactive IPython shell for Google App Engine on Mac OSX.
cd /to/project/folder/with/app.yaml
This script assumes numerous things:
* The path to your GAE SDK install.
* That you run the dev server with the specified datastore path:
e.g src --datastore_path=src/tmp/datastore
import os
import sys
app_root = os.path.dirname(os.path.abspath(__file__))
location = lambda x: os.path.join(app_root, x)
sys.path.insert(0, app_root)
sys.path.insert(1, '/usr/local/google_appengine')
from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore.datastore_sqlite_stub import (
from google.appengine.api.memcache.memcache_stub import MemcacheServiceStub
from google.appengine.api.taskqueue.taskqueue_stub import TaskQueueServiceStub
from google.appengine.api.urlfetch_stub import URLFetchServiceStub
from google.appengine.api import appinfo
ds_path = location("tmp/datastore")
# Load the app.yaml config.
app_ext_info = appinfo.LoadSingleAppInfo(file(location('app.yaml'), 'r'))
app_id = 'dev~%s' % app_ext_info.application
# Set the application ID to make stubs happy.
os.environ['APPLICATION_ID'] = app_id
# Init the proxy map and stubs.
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
# SQLite Datastore setup.
ds_opts = {
'require_indexes': True,
'verbose': True
ds_stub = DatastoreSqliteStub(app_id, ds_path, **ds_opts)
apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', ds_stub)
# Memcache setup.
mc_stub = MemcacheServiceStub()
apiproxy_stub_map.apiproxy.RegisterStub('memcache', mc_stub)
# Task queues setup.
tq_stub = TaskQueueServiceStub()
apiproxy_stub_map.apiproxy.RegisterStub('taskqueue', tq_stub)
# URLfetch service setup.
uf_stub = URLFetchServiceStub()
apiproxy_stub_map.apiproxy.RegisterStub('urlfetch', uf_stub)
# Pretty printing
import pprint
pp = pprint.PrettyPrinter(indent=4).pprint
# Perhaps load the models from your project
# so that they are already in the namespace.
# from project.models import *
from IPython import embed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment