Beispiel #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'])
Beispiel #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
Beispiel #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
Beispiel #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
     ]
Beispiel #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
Beispiel #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'])
Beispiel #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