From 227e36ce355b98224b8ee8960a2cd5f60272b99e Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 22 Jun 2018 13:21:08 +0200 Subject: [PATCH] API Formatter fixes --- dpaste/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dpaste/views.py b/dpaste/views.py index f1603d8..9bc8518 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -257,12 +257,13 @@ class APIView(View): ) s.save() + # Custom formatter for the API response formatter = getattr(self, '_format_{0}'.format(response_format), None) - if formatter: - response = self._format_default(s) - else: - response = formatter(s) - return HttpResponse(response) + if callable(formatter): + return HttpResponse(formatter(s)) + + # Otherwise use the default one. + return HttpResponse(self._format_default(s)) # -----------------------------------------------------------------------------