BadRequestError: app s~myapphr cannot access app dev~myapphr's data. Why?

白昼怎懂夜的黑 提交于 2019-12-17 16:51:01

问题


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?


回答1:


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.




回答2:


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~".



来源:https://stackoverflow.com/questions/9280613/badrequesterror-app-smyapphr-cannot-access-app-devmyapphrs-data-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!