From 66f8a5305fcf7e65ab13eb905857904885d6ac16 Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Wed, 19 Oct 2011 13:18:32 +0200 Subject: [PATCH] Remove the path attribute of FunctionDefinition, since a same FunctionDefinition could appears at different paths in an api tree --- wsme/controller.py | 8 ++------ wsme/tests/test_controller.py | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/wsme/controller.py b/wsme/controller.py index 02dc14f..bdf1488 100644 --- a/wsme/controller.py +++ b/wsme/controller.py @@ -44,8 +44,7 @@ def scan_api(controller, path=[]): a = getattr(controller, name) if inspect.ismethod(a): if hasattr(a, '_wsme_definition'): - a._wsme_definition.path = path - yield a._wsme_definition + yield path, a._wsme_definition elif inspect.isclass(a): continue else: @@ -98,9 +97,6 @@ class FunctionDefinition(object): #: Make sense only with :attr:`protocol_specific` functions. self.contenttype = None - #: Path of the function in the api tree. - self.path = None - #: Dictionnary of protocol-specific options. self.extra_options = {} @@ -254,7 +250,7 @@ class WSRoot(object): """ Returns the api description. - :rtype: list of :class:`FunctionDefinition` + :rtype: list of (path, :class:`FunctionDefinition`) """ if self._api is None: self._api = [i for i in scan_api(self)] diff --git a/wsme/tests/test_controller.py b/wsme/tests/test_controller.py index 65406bc..58ac906 100644 --- a/wsme/tests/test_controller.py +++ b/wsme/tests/test_controller.py @@ -142,8 +142,8 @@ class TestController(unittest.TestCase): api = list(scan_api(r)) assert len(api) == 1 - fd = api[0] - assert fd.path == ['ns'] + path, fd = api[0] + assert path == ['ns'] assert fd.name == 'multiply' def test_scan_subclass(self):