TypeError:'消息'对象不可调用

时间:2015-06-17 05:21:30

标签: python google-app-engine flask protorpc

我正在构建一个Flask应用并将其托管在Google App Engine中。我想将库protorpc集成到我的应用程序中,这样我就可以使用messages.Message构建自定义REST API,而无需使用Cloud Endpoints。为此我创建了一个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对象,并按如下方式使用它:

views.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

为什么我的消息无法调用?

0 个答案:

没有答案