request_vars.mako template does not handle forms with file data #42

Closed
everilae opened this Issue Oct 25, 2011 · 2 comments

Comments

Projects
None yet
1 participant

With a POST request from form accepting multipart/form-data containing a file request_vars.mako raises an exception

  File "/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-0.9.4post2-py2.7.egg/pyramid_debugtoolbar/panels/templates/request_vars.mako", line 88, in render_body
    <td>${", ".join(value)|h}</td>
TypeError: sequence item 0: expected string, instance found

It seems PDT is given a ready made instance instead of a plain string. A quick hack would be to

<td>${", ".join(isinstance(val, (str, unicode)) and val or repr(val) for val in value)|h}</td>

... or handle values before giving them to template (the better solution?).

The proposed quick hack btw does not handle empty string gracefully. Should use A if B else C or some such. All the more reason to handle values outside of the template :).

Sorry for momentarily forgetting about basestring. Test would be a bit prettier with isinstance(v, basestring) for python2. Does not change behaviour though, so I guess this one is closable as is.

blaflamme added a commit that referenced this issue Oct 27, 2011

@everilae everilae closed this Dec 22, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment