我正在使用应用程序工厂模式构建一个Flask应用程序。如果我在我的virtualenv上安装BPython,并使用外壳,它似乎无法获得应用程序上下文,因此当我尝试执行以下操作时:
>> 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做好了准备,所以我不知道为什么它没有创建应用程序上下文。
发布于 2016-09-09 17:11:12
我报告了this issue。这是BPython https://github.com/smurfix/flask-script/pull/165的一个问题
https://stackoverflow.com/questions/36047585
复制相似问题