mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-28 04:24:00 +03:00
small changes from pull request feedback
This commit is contained in:
parent
9f6d104dad
commit
3eb6fe5ad6
|
@ -1,4 +1,5 @@
|
|||
from django.conf.urls.defaults import patterns, url, include
|
||||
from collections import defaultdict
|
||||
|
||||
class ApiEntry(object):
|
||||
"""
|
||||
|
@ -35,17 +36,16 @@ class ApiEntry(object):
|
|||
)
|
||||
return urlpatterns
|
||||
|
||||
|
||||
@property
|
||||
def urls(self):
|
||||
return self.get_urls(), 'api', self.namespace
|
||||
urls = property(urls)
|
||||
|
||||
class DjangoRestFrameworkApi(object):
|
||||
app_name = 'api'
|
||||
namespace = 'api'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._registry = {}
|
||||
self._registry = defaultdict(lambda: defaultdict(list))
|
||||
super(DjangoRestFrameworkApi, self).__init__(*args, **kwargs)
|
||||
|
||||
def register(self, view, resource, namespace=None, name=None):
|
||||
|
@ -63,12 +63,6 @@ class DjangoRestFrameworkApi(object):
|
|||
|
||||
resource.api_name = name
|
||||
|
||||
if namespace not in self._registry:
|
||||
self._registry[namespace] = {}
|
||||
|
||||
if name not in self._registry[namespace]:
|
||||
self._registry[namespace][name] = []
|
||||
|
||||
api_entry = ApiEntry(resource, view, name, namespace)
|
||||
self._registry[namespace][name].append(api_entry)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user