在我的本地谷歌應用程序引擎開發環境中,我想使用ipython shell,特別是能夠檢出模型的數據是通過dev_server.py
, 創建的非常像django的manage.py shell
命令如何工作。Google App Engine本地(開發)IPython Shell
(這意味着sys.path
固定後IPython的外殼應啓動和app.yaml
讀取和分析,以及本地數據存儲就緒)
這個任何簡單的解決方案?
在我的本地谷歌應用程序引擎開發環境中,我想使用ipython shell,特別是能夠檢出模型的數據是通過dev_server.py
, 創建的非常像django的manage.py shell
命令如何工作。Google App Engine本地(開發)IPython Shell
(這意味着sys.path
固定後IPython的外殼應啓動和app.yaml
讀取和分析,以及本地數據存儲就緒)
這個任何簡單的解決方案?
對於初學者,您可以將您的應用程序根目錄和SDK根目錄(google_appengine
)放在您的Python路徑中。您還需要一些庫,如yaml
,它們可以安裝或添加到SDK的lib
目錄的庫路徑中。然後你可以導入模塊並調用一些功能。
>>> import sys
>>> sys.path.append('/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine')
當然,只要一個代碼路徑試圖撥打服務電話,該庫將拋出一個異常,稱它沒有被綁定到任何東西。要綁定的服務庫來測試存根,使用測試平臺庫:
>>> from google.appengine.ext import testbed
>>> tb = testbed.Testbed()
>>> tb.activate()
>>> tb.init_datastore_v3_stub()
>>> from google.appengine.ext import db
>>> import models
>>> m = models.Entry()
>>> m.title = ‘Test’
>>> m.put()
說句數據存儲測試存根使用開發服務器的數據存儲文件的路徑傳遞到文件init_datastore_v3_stub()
爲datastore_file
參數。有關更多信息,請參閱google.appengine.ext.testbed
中方法的文檔註釋。
有關測試平臺的更多信息:https://developers.google.com/appengine/docs/python/tools/localunittesting
這是我在乾淨的環境中用於測試的內容。我正在尋找一些簡單的方法來執行'gae_shell'來啓動一個本地shell,使用「當前」本地數據存儲。 – Udi
我所描述的似乎很容易通過IPython編寫腳本,包括將數據存儲文件傳遞給存根初始化程序。你需要它做更多? –
基本上你需要使用這樣的:https://developers.google.com/appengine/articles/remote_api
對於IPython的支持,你有兩個選擇:
(1)如果你正在使用Python 2.7版(和IPython的0.13),您將需要使用此嵌入一個IPython的外殼:
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
shell = TerminalInteractiveShell(user_ns=namespace)
shell.mainloop()
(2)如果你正在幹活與Python 2.5(和IPython的0.10.2)G您將需要使用此行嵌入一個IPython的外殼:
from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed(user_ns=namespace, banner=banner)
ipshell()
這是我使用的方法:https://gist.github.com/4624108所以你只要鍵入..
>> python console.py your-app-id
一旦運行dev_appserver.py 你會得到
starting module "default" running at: http://127.0.0.1:8080
Starting admin server at : http://localhost:8000
所以基本上你想要做的是訪問http://localhost:8000,那裏你會發現「互動控制檯」,你可以使用它來玩弄
這似乎是一個很好的開始:http://pythonwise.blogspot.co.il/2011/02/appengine-work-environment。 html – Udi