Skip navigation.

Google App Engine remote_api

The example provided in docs for Google App Engine remote_api did not quit work for me right away.  Here are some modifications that will make it work.

First of all (thanks to the following post) use instead the following code (for OSX) for

import code
import getpass
import os
import sys

DIR_PATH = "/Applications/"

  os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),

sys.path = EXTRA_PATHS + sys.path

from google.appengine.ext.remote_api import remote_api_stub
from google.appengine.ext import db

def auth_func():
  return raw_input('Username:'), getpass.getpass('Password:')

if len(sys.argv) < 2:
  print "Usage: %s app_id [host]" % (sys.argv[0],)
app_id = sys.argv[1]
if len(sys.argv) > 2:
  host = sys.argv[2]
  host = '' % app_id

remote_api_stub.ConfigureRemoteDatastore(app_id, '/remote_api', auth_func, host)

code.interact('App Engine interactive console for %s' % (app_id,), None, locals())

Don't forget to comment out (or change from *) the in app.yaml

#- url: /.*
#  script:

- url: /remote_api
  script: $PYTHON_LIB/google/appengine/ext/remote_api/
  login: admin


Otherwise you will get the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Applications/google_appengine/google/appengine/ext/db/", line 1336, in __iter__
  File "/Applications/google_appengine/google/appengine/ext/db/", line 1742, in run
    query_run = self._proto_query.Run(*self._args, **self._kwds)
  File "/Applications/google_appengine/google/appengine/ext/gql/", line 657, in Run
    res = bind_results.Get(self.__limit, offset)
  File "/Applications/google_appengine/google/appengine/api/", line 942, in Get
    return self._Run(limit, offset)._Next(limit)
  File "/Applications/google_appengine/google/appengine/api/", line 1536, in _Next
    apiproxy_stub_map.MakeSyncCall('datastore_v3', 'Next', req, result)
  File "/Applications/google_appengine/google/appengine/api/", line 68, in MakeSyncCall
    apiproxy.MakeSyncCall(service, call, request, response)
  File "/Applications/google_appengine/google/appengine/api/", line 240, in MakeSyncCall
    stub.MakeSyncCall(service, call, request, response)
  File "/Applications/google_appengine/google/appengine/ext/remote_api/", line 181, in MakeSyncCall
    handler(request, response)
  File "/Applications/google_appengine/google/appengine/ext/remote_api/", line 219, in _Dynamic_Next
    'remote_datastore', 'RunQuery', request, query_result)
  File "/Applications/google_appengine/google/appengine/ext/remote_api/", line 147, in MakeSyncCall
  File "/Applications/google_appengine/google/appengine/tools/", line 344, in Send
    f =
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 389, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 502, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 427, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 361, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/", line 510, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 404: Not Found

The guestbook example gave the following error:

>>> import helloworld
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/neil/Documents/workspace/helloworld/src/", line 5, in <module>
    from google.appengine.ext import webapp
  File "/Applications/google_appengine/google/appengine/ext/webapp/", line 68, in <module>
    import webob
ImportError: No module named webob

Instead of using somewhat convoluted example provided by the docs

Just copy and paste the following sections separated by bold comments (make sure to paste them separately):

from google.appengine.ext import db

class Greeting(db.Model):
  author = db.UserProperty()
  content = db.StringProperty(multiline=True)
  date = db.DateTimeProperty(auto_now_add=True)

# Now make sure to hit enter couple of times to get out of ident mode

q = db.GqlQuery("SELECT * FROM Greeting ORDER BY date DESC LIMIT 10")
results = q.fetch(5)

# Enter the username and password

for r in results:
    print r.content