python - why my url routing isn't working? -
class respondersapi(methodview): # class based view restful services ... #now have url maps here users_api = respondersapi.as_view('users_api', userlevel=1) admin_mod.add_url_rule("/user/uid/<objectid:user_id>", view_func = users_api, methods=["put", "delete"]) admin_mod.add_url_rule("/user", defaults={'page': 1}, view_func = users_api, methods=["get"]) admin_mod.add_url_rule("/user/page/<int:page>", view_func = users_api, methods=["get"]) admin_mod.add_url_rule("/user/new", view_func = users_api, methods=["post"],)
as can see above, problem 1 can't reach 4th routing rule. objectid converter here's whats going on:
>>> url_for('.users_api', page=1) '/admin/user' >>> url_for('.users_api', page=2) '/admin/user/page/2' >>> url_for('.users_api', user_id=users[0].id) '/admin/user?user_id=521781f4fe8974125cef5ea9' # not expected
the objectid converter the 1 armin ronacher. put debug codes there , discovered isn't fired. thought has order of creating url rules, tried declaring url rule objectid before other rules declared; doesn't @ all. wrong codes? here current url map:
map([ <rule '/admin/user/new' (post, options) -> admin_mod.users_api>, <rule '/admin/user/uid/<user_id>' (put, options, delete) -> admin_mod.users_api>, <rule '/admin/user/page/<page>' (head, options, get) -> admin_mod.users_api>, <rule '/admin/user' (head, options, get) -> admin_mod.users_api>, ... # , bunch of rules .. ])
Comments
Post a Comment