mitsuhiko/flask — Issue #353: MethodViews for API example is missing parameter
Author: toddself
Created: 2011-11-21 15:14:32+00:00
State: open

On http://flask.pocoo.org/docs/views/#method-views-for-apis
At the end of the page in the very last code example you have:

def register_api(view, endpoint, url, pk='id', pk_type='int'):
view_func = view.as_view(endpoint)
app.add_url_rule(url, defaults={pk: None},
view_func=view_func, methods=['GET', 'POST'])
app.add_url_rule('%s<%s:%s>' % (url, pk), view_func=view_func,
methods=['GET', 'PUT', 'DELETE'])

register_api(UserAPI, 'user_api', '/users/', pk='user_id')

The last ```app.add_url_rule``` has three substitutions in the string, but the tuple only has two items.

It should read:

app.add_url_rule('%s<%s:%s>' % (url, pk_type, pk), view_func=view_func,
methods=['GET', 'PUT', 'DELETE'])