开发中的应用程序的 App Engine 控制台?
有没有可能为正在开发的应用程序提供一个类似 remote_api_shell.py 的功能呢?这个 remote_api_shell.py 让我们指定已经部署的应用,然后给我们一个可以交互的控制台。我在使用 remote_api_shell 的时候发现了一个限制:如果我切换到我的开发目录,就无法使用我正在编写的 Google API 模块。
我觉得需要一个本地控制台,因为我在尝试为正在开发的应用建模,必须不断尝试和修改我的模型,而不需要经过请求处理层或者上传应用。这种方式可以让我在交互式会话中尝试模型的各种功能。con.appspot.com 提供了一个浏览器控制台,但我觉得不太适合编写类或者导入小的测试模块。
像这样的功能是行不通的,因为它需要一个 _app 来支撑。
import setapipaths # Sets the paths to google appengine apis
import sys
from google.appengine.ext import db
class TodoList(db.Model):
name = db.StringProperty(required=True)
class TodoItem(db.Model):
user = db.UserProperty(required=True)
date = db.DateTimeProperty(auto_now_add=True)
belongs_to = db.Reference(TodoList)
description = db.StringProperty(multiline=True)
rating = db.IntegerProperty(required=True)
score = db.IntegerProperty(required=True)
todolist = TodoList()
todolist.name = "firstline"
todolist.put()
obj1 = TodoItem(user='senthil',belongs_to=todolist.key(),description="something",rating=10,score=5)
obj1.put()
1 个回答
1
哎呀!我在发完这个问题后就找到了答案。
第一步:在一个终端窗口中运行你的开发应用。
python dev_appserver.py app
这个应用默认是在8080端口运行的。
第二步:打开另一个终端窗口,使用remote_api_shell.py来连接正在运行的实例。
PYTHONPATH=. remote_api_shell.py -s localhost:8080 app
这样你就可以得到一个应用控制台,可以进行实验了。
之前我试图在本地应用上使用remote_api_shell.py
,但没有先运行它。
更新:另外,我发现http://localhost:8080/_ah/admin/interactive控制台可以让你写完整的代码片段。