从行为访问ndb模型

时间:2014-11-04 10:07:56

标签: python google-app-engine flask bdd

我认为这可能是不可能的,但我一直想知道......

我正在构建一个烧瓶应用程序(在谷歌应用程序引擎上运行) 我正在使用表现为BDD工具。 如果我通过浏览器自动化将所有内容分开,这一切都很有效。

我想要的是查看数据结构(在我的情况下,所以我可以检查我的模拟用户属性)。当我尝试:

from application.models import MyUserModel

我收到以下错误

  File "/usr/local/bin/behave", line 8, in <module>
    load_entry_point('behave==1.2.3', 'console_scripts', 'behave')()
  File "/Library/Python/2.7/site-packages/behave/__main__.py", line 111, in main
    failed = runner.run()
  File "/Library/Python/2.7/site-packages/behave/runner.py", line 474, in run
    return self.run_with_paths()
  File "/Library/Python/2.7/site-packages/behave/runner.py", line 477, in run_with_paths
    self.load_hooks()
  File "/Library/Python/2.7/site-packages/behave/runner.py", line 437, in load_hooks
    exec_file(hooks_path, self.hooks)
  File "/Library/Python/2.7/site-packages/behave/runner.py", line 283, in exec_file
    execfile(filename, globals, locals)
  File "/Users/ido/Documents/workspace/talknet-0.2.02/src/features/environment.py", line 13, in <module>
    import application
  File "/Users/ido/Documents/workspace/talknet-0.2.02/src/application/__init__.py", line 1, in <module>
    from flask import g, Flask, render_template
  File "/Users/ido/Documents/workspace/talknet-0.2.02/src/lib/flask/__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
ImportError: No module named jinja2

我知道我的功能和步骤没有在appserver上下文中运行。 但我还没有。这是一个导入问题......

有没有办法解决这个问题?

1 个答案:

答案 0 :(得分:1)

要修复您提供的示例中的异常,请添加:

libraries:
- name: jinja2
  version: latest

app.yaml文件。

在此处查看更多信息:https://cloud.google.com/appengine/docs/python/tools/libraries27