From 098c4dd376502d1c7bbdf91d96004bfb029c3f5b Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Fri, 9 Mar 2012 09:28:14 +0000 Subject: Be clear with template_to_temp_file's arguments It's not obvious what template_to_temp_file is doing with its undefined arguments. The Zen of Python states: Explicit is better than implicit. Readability counts. An alternative solution would be to rename the function to loader_render_to_tempfile or similar, but this fix is more backwards-compatible. --- wkhtmltopdf/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wkhtmltopdf') diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py index 4666f4c..cf01f43 100644 --- a/wkhtmltopdf/utils.py +++ b/wkhtmltopdf/utils.py @@ -57,12 +57,12 @@ def wkhtmltopdf(pages, output=None, **kwargs): return output -def template_to_temp_file(*args, **kwargs): +def template_to_temp_file(template_name, dictionary=None, context_instance=None): """ Renders a template to a temp file, and returns the path of the file. """ file_descriptor, tempfile_path = mkstemp(suffix='.html') with fdopen(file_descriptor, 'wt') as f: - f.write(smart_str(loader.render_to_string(*args, **kwargs))) + f.write(smart_str(loader.render_to_string(template_name, dictionary=dictionary, context_instance=context_instance))) return tempfile_path -- cgit v1.2.3