在BPython中使用Flask-Script shell无法获取应用程序上下文

时间:2016-03-16 21:46:44

标签: python shell flask ipython bpython

我正在使用app工厂模式构建Flask应用程序。如果我在我的virtualenv上安装BPython并使用shell,它似乎无法获取应用程序上下文,因此当我尝试执行以下操作时:

>> Role.query.all()

我得到一个RuntimeError:

application not registered on db instance and no application bound to current context

我必须使用创建应用程序上下文并按照以下方式执行:

with app.app_context():
    ...
    do stuff

但是,如果我使用IPython,它可以正常工作。在文档中它表示它已经为BPython和IPython做好了准备,所以我不知道为什么它没有创建应用程序上下文。

1 个答案:

答案 0 :(得分:0)

我报告了this issue。这是BPython https://github.com/smurfix/flask-script/pull/165

的一个问题