Example #1
0
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'])
Example #2
0
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
Example #3
0
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
Example #4
0
 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
     ]
Example #5
0
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
Example #6
0
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'])
Example #7
0
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