Search code examples
pythongoogle-app-enginedjango-nonrel

django non rel and google app engine: remote api issue


I am deploying a django-nonrel app on Google App Engine. The app deploys alright but I can't login to the remote shell.

This is my app.yaml file:

application: masnun
version: 1
runtime: python
api_version: 1

builtins:
- remote_api: on

inbound_services:
- warmup

handlers:
- url: /_ah/queue/deferred
  script: djangoappengine/deferred/handler.py
  login: admin

- url: /media/admin
  static_dir: django/contrib/admin/media
  expiration: '0'

- url: /.*
  script: djangoappengine/main/main.py

But I am getting an error:

urllib2.URLError: <urlopen error HTTP Error 500: Internal Server Error
Couldn't reach remote_api handler at https://masnun.appspot.com/_ah/remote_api(/.*)?.
Make sure you've deployed your project and installed a remote_api handler in app.yaml.>

Please help me out!

Update: When using Python2.5, getting this error:

DEBUG:google.appengine.tools.appengine_rpc:Got http error, this is try #3
DEBUG:google.appengine.tools.appengine_rpc:Sending HTTPS request:
GET /_ah/remote_api(/.*)? HTTPS/1.1
Host: masnun.appspot.com
X-appcfg-api-version: 1
Content-type: application/octet-stream
User-agent: Google-remote_api/1.0 Linux/2.6.35-25-generic Python/2.5.5.final.0

Solution

  • The problem is with

    GET /_ah/remote_api(/.*)? HTTPS/1.1

    If you notice, the URL contains invalid characters "(/.*)?" towards the end.

    Assuming you are using django-nonrel, it is an easy fix. Open the file

    djangoappengine/db/base.py
    

    and change the line

    self.remote_api_path = handler.url
    

    to

    self.remote_api_path = handler.url.split('(')[0] # remove '(/.*)' introduced in newer GAE
    

    and that should take care of ensuring the URL is correct.