0

我正在构建一个 Flask 应用程序并将其托管在 Google App Engine 中。我想将该库集成到我的应用程序中,这样我就可以在不使用 Cloud Endpoints的情况下protorpc构建自定义 REST API 。messages.Message为此,我创建了一个apis_messages.py包含以下代码的文件:

api_messages.py:

from protorpc import messages

package = 'Hello'

class StoredMessage(messages.Message):
    """Boolean representing stored flag"""
    stored = messages.BooleanField(1)

然后我在我的导入这个StoredMessage对象views.py并使用它,如下所示:

视图.py:

@app.route('/venue_create')
def venue_create():
    r_id = request.form['r_id']
    val = Venue.get_by_id(r_id)
    if val is None:
        r = Venue.create()
    # I could use jsonify, but I want to give protorpc a chance
    # return jsonify(Stored = True)
    return StoredMessage(stored = True)

使用此代码,我不断收到以下错误:

Traceback (most recent call last):
  File "/src/lib/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/src/lib/flask/app.py", line 1478, in full_dispatch_request
    response = self.make_response(rv)
  File "/src/lib/flask/app.py", line 1577, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "/src/lib/werkzeug/wrappers.py", line 827, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "/src/lib/werkzeug/test.py", line 855, in run_wsgi_app
    app_iter = app(environ, start_response)
TypeError: 'StoredMessage' object is not callable

为什么我的消息不可调用?

4

0 回答 0