From 0bdaeffbe466d3e03bc32f18c4e39ad91f3cddf4 Mon Sep 17 00:00:00 2001 From: yang Date: Wed, 6 Aug 2014 18:15:53 +0800 Subject: [PATCH 1/2] fix when use some complex decorator --- flask_classy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flask_classy.py b/flask_classy.py index e0c5ccd..c3689e6 100644 --- a/flask_classy.py +++ b/flask_classy.py @@ -241,7 +241,7 @@ def build_rule(cls, rule, method=None): ignored_rule_args += cls.base_args if method: - args = get_true_argspec(method)[0] + args = get_true_argspec(method, method.__name__)[0] for arg in args: if arg not in ignored_rule_args: rule_parts.append("<%s>" % arg) @@ -291,7 +291,7 @@ def get_interesting_members(base_class, cls): and not member[0].startswith("after_")] -def get_true_argspec(method): +def get_true_argspec(method, raw_method_name=None): """Drills through layers of decorators attempting to locate the actual argspec for the method.""" argspec = inspect.getargspec(method) @@ -301,6 +301,8 @@ def get_true_argspec(method): if hasattr(method, '__func__'): method = method.__func__ if not hasattr(method, '__closure__') or method.__closure__ is None: + if method.__name__ != raw_method_name: + return raise DecoratorCompatibilityError closure = method.__closure__ @@ -311,7 +313,7 @@ def get_true_argspec(method): if not inspect.isfunction(inner_method) \ and not inspect.ismethod(inner_method): continue - true_argspec = get_true_argspec(inner_method) + true_argspec = get_true_argspec(inner_method, raw_method_name) if true_argspec: return true_argspec From c75622e92c0c0b957a7e1533259b8536bb412b3c Mon Sep 17 00:00:00 2001 From: yang Date: Thu, 28 Aug 2014 15:20:18 +0800 Subject: [PATCH 2/2] fix route for empty string when use route '', the route will become '/' --- flask_classy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flask_classy.py b/flask_classy.py index c3689e6..79d2531 100644 --- a/flask_classy.py +++ b/flask_classy.py @@ -117,6 +117,10 @@ def register(cls, app, route_base=None, subdomain=None, route_prefix=None, else: endpoint = "%s_%d" % (route_name, idx,) + trailing_slash = options.pop('trailing_slash',True) + if not trailing_slash: + rule = rule.rstrip("/") + app.add_url_rule(rule, endpoint, proxy, subdomain=subdomain, **options) elif name in special_methods: