[英]How to access Google App Engine's dev server data from the command line
I regularly download my Google App Engine production data locally (using a custom script that basically calls appcfg.py download_data
) and upload it to the development server so that the data in my development environment matches production. 我会定期在本地下载Google App Engine生产数据(使用一个自定义脚本,该脚本基本上调用appcfg.py download_data
)并将其上传到开发服务器,以使开发环境中的数据与生产匹配。 You can find the scripts on Launchpad: 您可以在启动板上找到脚本:
./extra/manipular-datos.py --download
) 下载脚本 (通过./extra/manipular-datos.py --download
) ./extra/launcher.py
) 启动器脚本 (通过./extra/launcher.py
) This is what the launcher script does: 这是启动器脚本的作用:
Everything was working fine until GAE 1.5.2. 一切正常,直到GAE 1.5.2。 At that point the development server changed to prefix dev~
, so I added --default_partition=''
to launch the dev server. 在这一点上开发服务器更改为前缀dev~
,所以我加了--default_partition=''
启动开发服务器。 However now the password-changing script seems to not access the loaded data, it always returns 0 entities for normal or admin users. 但是,现在更改密码的脚本似乎无法访问已加载的数据,对于普通用户或管理员用户,它始终返回0个实体。 I'm wondering how to access the data from the command line, so explicitely not from an url to prevent this from ever happening on the production server. 我想知道如何从命令行访问数据,因此明确地不是从url访问数据,以防止在生产服务器上发生这种情况。 The scripts in ./extra
are not uploaded to GAE, they can thus not be executed from there. ./extra
中的脚本不会上载到GAE,因此无法从那里执行。
To give you an idea (but look at the script for more context), this is what the script used to do (and was working until GAE <= 1.5.1): 为了给您一个主意(但请查看脚本以获取更多上下文),这是该脚本曾经做过的事情(一直有效到GAE <= 1.5.1为止):
args, option_dict = ParseArguments(['', colCasaBasePath])
config, matcher = LoadAppConfig(colCasaBasePath, {})
SetupStubs(config.application, **option_dict)
The the application's models can be accessed just normally: 可以正常访问应用程序的模型:
from src.models import WebUser, ScyllaUser
for tipo in (WebUser, ScyllaUser):
usuarios = tipo.all()
# Now len(usuarios) == 0
What has been changed (after GAE 1.5.1) that breaks my GAE data-accessing script? (在GAE 1.5.1之后)更改了哪些内容,从而破坏了我的GAE数据访问脚本? How would you perform such a workflow? 您将如何执行这样的工作流程?
The trick is to add the --default_partition=
argument to the ParseArguments()
call in the script that accesses the GAE data: 诀窍是在访问GAE数据的脚本中将--default_partition=
参数添加到ParseArguments()
调用中:
args, option_dict = ParseArguments(['', colCasaBasePath, "--default_partition="])
Note that there is nothing after the =
, that's what put me off. 请注意, =
之后没有任何内容,这就是让我失望的原因。 I first tried adding "--default_partition=''"
, but that didn't have any effect (but also didn't result in errors). 我首先尝试添加"--default_partition=''"
,但这没有任何效果(但也没有导致错误)。
After adding that call the script is again able to loop over all the users that have been loaded in the dev datastore. 添加该调用之后,脚本再次能够遍历已在dev数据存储区中加载的所有用户。 You can see the changes I had to make on Launchpad . 您可以在Launchpad上看到我必须进行的更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.