2011-12-28 23 views
0

是否有可能爲開發中的應用程序提供類似remote_api_shell.py的功能。 remote_api_shell.py要求我們指向已部署的應用程序並提供repl控制檯。我在使用remote_api_shell時發現了以下限制,如果我將os.chdir添加到我的開發目錄中,則無法使用我正在使用google apis編寫的模塊。用於開發應用程序的appengine控制檯?

我覺得對本地控制檯的需求,因爲我試圖數據模型正在開發的應用程序,我只好不斷嘗試/改變我的模型,而無需通過請求處理層會或上傳應用程序。在交互式會話中嘗試模型的各種功能可能是很好的選擇。 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

Doh!我在發佈此問題時儘快找到了答案。

第1步:運行在開發你的應用程序在一個shell會話

python dev_appserver.py app 

下端口的應用程序默認運行8080

第2步:打開另一個shell會話,並使用remote_api_shell.py來連接到正在運行的實例。

PYTHONPATH=. remote_api_shell.py -s localhost:8080 app 

在那裏您將獲得用於試驗的應用程序控制臺。

以前我是想在本地應用程序中使用remote_api_shell.py,不運行它。

更新:另外,我發現http://localhost:8080/_ah/admin/interactive控制檯提供了寫完整片段的能力。

相關問題