From a4290c7ae9a5dfa8fbeaf16a20e53e657037f5ab Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Fri, 28 Oct 2011 09:47:33 +0200 Subject: [PATCH] Bugfix: a complex type used only in validate and never in expose was not registered --- wsme/controller.py | 1 + wsme/tests/test_controller.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/wsme/controller.py b/wsme/controller.py index f888b4a..b35671d 100644 --- a/wsme/controller.py +++ b/wsme/controller.py @@ -230,6 +230,7 @@ class validate(object): args = args[1:] for i, argname in enumerate(args): datatype = self.param_types[i] + register_type(datatype) mandatory = defaults is None or i < (len(args) - len(defaults)) default = None if not mandatory: diff --git a/wsme/tests/test_controller.py b/wsme/tests/test_controller.py index 3383907..9880f4b 100644 --- a/wsme/tests/test_controller.py +++ b/wsme/tests/test_controller.py @@ -8,6 +8,7 @@ import webtest from wsme import * from wsme.controller import getprotocol, scan_api, pexpose from wsme.controller import FunctionArgument, FunctionDefinition, CallContext +from wsme.types import iscomplex import wsme.wsgi @@ -90,12 +91,20 @@ class TestController(unittest.TestCase): assert MyWS.getint._wsme_definition.return_type == int def test_validate(self): + class ComplexType(object): + attr = int + class MyWS(object): @expose(int) @validate(int, int, int) def add(self, a, b, c=0): return a + b + c + @expose(bool) + @validate(ComplexType) + def setcplx(self, obj): + pass + args = MyWS.add._wsme_definition.arguments assert args[0].name == 'a' @@ -113,6 +122,8 @@ class TestController(unittest.TestCase): assert not args[2].mandatory assert args[2].default == 0 + assert iscomplex(ComplexType) + def test_register_protocol(self): import wsme.controller wsme.controller.register_protocol(DummyProtocol)