diff options
author | James Turnbull <james@incuna.com> | 2012-03-09 09:28:14 +0000 |
---|---|---|
committer | James Turnbull <james@incuna.com> | 2012-03-09 09:28:14 +0000 |
commit | 098c4dd376502d1c7bbdf91d96004bfb029c3f5b (patch) | |
tree | 0090b4f13d5a6e1bab487e4832398c19c8cc30ee | |
parent | 6869f502fa54ce3a2b677464d64bc1d7a5c73b94 (diff) | |
download | django-wkhtmltopdf-098c4dd376502d1c7bbdf91d96004bfb029c3f5b.tar.gz django-wkhtmltopdf-098c4dd376502d1c7bbdf91d96004bfb029c3f5b.tar.bz2 django-wkhtmltopdf-098c4dd376502d1c7bbdf91d96004bfb029c3f5b.zip |
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.
-rw-r--r-- | wkhtmltopdf/utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
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 |