allow setting method_name to None
diff --git a/xos/api/import_methods.py b/xos/api/import_methods.py
index dd1c338..d53556c 100644
--- a/xos/api/import_methods.py
+++ b/xos/api/import_methods.py
@@ -56,8 +56,11 @@
method_kind = getattr(c, "method_kind", None)
method_name = getattr(c, "method_name", None)
- if method_kind and method_name:
- method_name = os.path.join(api_path, method_name)
+ if method_kind:
+ if method_name:
+ method_name = os.path.join(api_path, method_name)
+ else:
+ method_name = api_path
view_urls.append( (method_kind, method_name, classname, c) )
elif os.path.isdir(pathname):
diff --git a/xos/api/xosapi_helpers.py b/xos/api/xosapi_helpers.py
index 8011c11..ee3ed00 100644
--- a/xos/api/xosapi_helpers.py
+++ b/xos/api/xosapi_helpers.py
@@ -69,14 +69,21 @@
api_path=""
@classmethod
+ def get_api_method_path(self):
+ if self.method_name:
+ return self.api_path + self.method_name + "/"
+ else:
+ return self.api_path
+
+ @classmethod
def detail_url(self, pattern, viewdict, name):
- return url(self.api_path + self.method_name + r'/(?P<pk>[a-zA-Z0-9\-]+)/' + pattern,
+ return url(self.get_api_method_path() + r'(?P<pk>[a-zA-Z0-9\-]+)/' + pattern,
self.as_view(viewdict),
name=self.base_name+"_"+name)
@classmethod
def list_url(self, pattern, viewdict, name):
- return url(self.api_path + self.method_name + r'/' + pattern,
+ return url(self.get_api_method_path() + pattern,
self.as_view(viewdict),
name=self.base_name+"_"+name)
@@ -86,7 +93,7 @@
patterns = []
- patterns.append(url(self.api_path + self.method_name + '/$', self.as_view({'get': 'list', 'post': 'create'}), name=self.base_name+'_list'))
- patterns.append(url(self.api_path + self.method_name + '/(?P<pk>[a-zA-Z0-9\-]+)/$', self.as_view({'get': 'retrieve', 'put': 'update', 'post': 'update', 'delete': 'destroy', 'patch': 'partial_update'}), name=self.base_name+'_detail'))
+ patterns.append(url(self.get_api_method_path() + '$', self.as_view({'get': 'list', 'post': 'create'}), name=self.base_name+'_list'))
+ patterns.append(url(self.get_api_method_path() + '(?P<pk>[a-zA-Z0-9\-]+)/$', self.as_view({'get': 'retrieve', 'put': 'update', 'post': 'update', 'delete': 'destroy', 'patch': 'partial_update'}), name=self.base_name+'_detail'))
return patterns