Skip to content

Commit

Permalink
warn if handle_request returns dict
Browse files Browse the repository at this point in the history
--HG--
branch : warn_dict_retval
  • Loading branch information
AvdN committed Jul 25, 2023
1 parent 0c2edf2 commit d3e77bd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lona/view_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down

0 comments on commit d3e77bd

Please sign in to comment.