From d3e77bd3d1e1c077f48df5b64d64dd6196caf65e Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Tue, 25 Jul 2023 13:51:07 +0200 Subject: [PATCH] warn if handle_request returns dict --HG-- branch : warn_dict_retval --- lona/view_runtime.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lona/view_runtime.py b/lona/view_runtime.py index 555e7e47..95e6e2f7 100644 --- a/lona/view_runtime.py +++ b/lona/view_runtime.py @@ -344,8 +344,19 @@ def start(self): self.send_view_start() # run view + handle_request_return_value = self.view.handle_request(self.request) + if isinstance(handle_request_return_value, dict): + co = self.view.handle_request.__func__.__code__ + logger.warning( + 'Deprecated use of dict as return value of method handle_request {co_fn}, line {co_fln}', + extra={'co_fn': co.co_filename, 'cofln': co.co_firstlineno}, + ) + logger.warning( + ' (see: https://lona-web.org/1.x/api-reference/views.html#response-objects)', + ) + response = parse_view_return_value( - return_value=self.view.handle_request(self.request), + return_value=handle_request_return_value, interactive=self.route and self.route.interactive, )