BadRequestError: application s ~ myapphr cannot access dev ~ myapphr application data. What for?

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

I get the following error:

BadRequestError: application s ~ myapphr cannot access application data dev ~ myapphr

Based on this code:

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

I access my application from dev.myapp.appspot.com, which is an alias of myapphr. device_id was created in the same version of dev.myapphr.

What's happening?

+3
source share
2 answers

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

+3
source

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

+3
source

All Articles