I am building a Flask app and hosting it in Google App Engine. I would like to integrate the library protorpc
into my app so I can build a custom REST API using messages.Message
without using Cloud Endpoints. For this I created a apis_messages.py
file that contains the following code:
api_messages.py:
from protorpc import messages
package = 'Hello'
class StoredMessage(messages.Message):
"""Boolean representing stored flag"""
stored = messages.BooleanField(1)
I then import this StoredMessage
object in my views.py
and use it as follows:
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)
With this code I keep getting the following error:
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
Why is my Message not callable?