def add_resource(app, resource, pk='pk'): uri, endpoint, view_func = get_args(resource) app.add_url_rule(normalize_uri(uri), view_func=view_func, methods=['OPTIONS', 'GET', 'POST', 'DELETE']) app.add_url_rule(normalize_uri('%s/<%s>' % (uri, pk)), view_func=view_func, methods=['OPTIONS', 'GET', 'PUT', 'PATCH', 'DELETE'])
def add_resource(resource, pk='pk'): uri, _, view_cls = get_args(resource) urlpatterns = patterns('', url_rule(r'^%s$' % normalize_uri(uri), view_cls, methods=['OPTIONS', 'GET', 'POST', 'DELETE']), url_rule(r'^%s$' % normalize_uri('%s/(?P<pk>\w+)' % uri), view_cls, methods=['OPTIONS', 'GET', 'PUT', 'PATCH', 'DELETE']) ) return urlpatterns
def __init__(self, *arg, **kwargs): super(Root, self).__init__(*arg, **kwargs) self.links = [ { 'href': normalize_uri(settings.DOMAIN_NAME + r.uri), 'title': r.name } for r in self.resources ]
def make_root(resource, pk='pk'): uri, _, view_cls = get_args(resource) urlpatterns = patterns( '', url_rule(r'^%s$' % normalize_uri(uri), view_cls, methods=['GET'])) return urlpatterns
def make_root(app, resource, pk='pk'): uri, endpoint, view_func = get_args(resource) app.add_url_rule(normalize_uri(uri), view_func=view_func, methods=['GET'])
def make_root(resource, pk='pk'): uri, _, view_cls = get_args(resource) urlpatterns = patterns('', url_rule(r'^%s$' % normalize_uri(uri), view_cls, methods=['GET']) ) return urlpatterns