4

I am using the Python 2.7 runtime with NDB from the 1.6.2 SDK on Google App Engine.

I get the following error:

BadRequestError: app s~myapphr cannot access app dev~myapphr's data

Originating from this code:

device = model.Key(urlsafe=device_id).get()

I am accessing my app from dev.myapp.appspot.com that is aliased to myapphr. device_id was created on the same dev.myapphr version.

What is going on?

Dan
  • 5,013
  • 5
  • 33
  • 59

2 Answers2

4

the dev server has a default default_partition of 'dev' and on production, HRD apps get a partition of 's'. If you create a urlsafe key on the dev server and store it as a string it will not work on a the production server with a different partition. the way to make keys portable is to save them in a ReferenceProperty with db or KeyProperty on ndb.

johnlockwood
  • 247
  • 2
  • 7
3

The prefix you see there ("s~" and "dev~") is called a partition. You can use the --default_partition flag for dev_appserver.py to change the prefix from "dev~" to "s~".

schuppe
  • 2,033
  • 10
  • 10
  • Thank you. The thing that confused me was that I called my development version dev on production and thought that had something to do with it. – Dan Feb 14 '12 at 17:55
  • Also note you can set this --default_partition in the "Info..." in right-click menu if using GoogleAppEngineLauncher. – Bemmu Jun 01 '12 at 04:21
  • 3
    Note that this is [deprecated since v1.7.6](https://developers.google.com/appengine/docs/python/tools/old_devserver). – OJFord Sep 18 '14 at 20:59