From 2fc62e5be9f0f4394507505c92b5174532db5e10 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Mon, 21 May 2012 15:56:21 +0100 Subject: Pass around args and kwargs in PDFResponse In case you want to pass more things up to HttpResponse. Can't pass filename down though. --- wkhtmltopdf/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'wkhtmltopdf') diff --git a/wkhtmltopdf/views.py b/wkhtmltopdf/views.py index 36efaf5..164f94f 100644 --- a/wkhtmltopdf/views.py +++ b/wkhtmltopdf/views.py @@ -11,10 +11,11 @@ from wkhtmltopdf.utils import template_to_temp_file, wkhtmltopdf class PDFResponse(HttpResponse): - def __init__(self, content, **kwargs): - super(PDFResponse, self).__init__(content, 'application/pdf') - if 'filename' in kwargs: - header_content = 'attachment; filename={0}'.format(kwargs.get('filename')) + def __init__(self, content, *args, **kwargs): + filename = kwargs.pop('filename', None) + super(PDFResponse, self).__init__(content, 'application/pdf', *args, **kwargs) + if filename: + header_content = 'attachment; filename={0}'.format(filename) self.__setitem__('Content-Disposition', header_content) @@ -55,7 +56,7 @@ class PDFTemplateView(TemplateView): output = wkhtmltopdf(page_path, **pdf_kwargs) if self._tmp_files: map(os.remove, self._tmp_files) - return self.response(output, self.get_filename()) + return self.response(output, filename=self.get_filename()) def get_filename(self): return self.filename -- cgit v1.2.3