From 5c4499658c92278a1004115b659a67c71503dbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 22 Sep 2016 17:20:44 +0200 Subject: [PATCH] Allow calling a @attract_project_view()-decorated function efficiently. @attract_project_view() now checks to see if you're passing an SDK resource as the first parameter. In that case it assumes you know what you're doing and simply passes all parameters as-is. --- attract/modules.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/attract/modules.py b/attract/modules.py index 66a63fe..0965e0f 100644 --- a/attract/modules.py +++ b/attract/modules.py @@ -60,6 +60,12 @@ def attract_project_view(extra_project_projections=None, extension_props=False): def decorator(wrapped): @functools.wraps(wrapped) def wrapper(project_url, *args, **kwargs): + if isinstance(project_url, pillarsdk.Resource): + # This is already a resource, so this call probably is from one + # view to another. Assume the caller knows what he's doing and + # just pass everything along. + return wrapped(project_url, *args, **kwargs) + api = pillar_api() project = pillarsdk.Project.find_by_url(