Remove the path attribute of FunctionDefinition, since a same FunctionDefinition could appears at different paths in an api tree

This commit is contained in:
Christophe de Vienne
2011-10-19 13:18:32 +02:00
parent ced239de1b
commit 66f8a5305f
2 changed files with 4 additions and 8 deletions

View File

@@ -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)]

View File

@@ -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):