Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

show_placeholder_by_id doesn't fail gracefully #963

Closed
kezabelle opened this Issue Aug 23, 2011 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

kezabelle commented Aug 23, 2011

This is similar in scope to #422, in that where that ticket covers the templatetag raising errors loudly when a page does not exist, so this one covers it erroring loudly* when a placeholder does not exist.

*against Django's dictate that render() should never raise TemplateSyntaxError or any other exception. It should fail silently, just as template filters should, hence my filing it as a bug

What I'd expect:

  • Based on looking at the code, (specifically, line 327, line 340 and line 357 as of 03e7d01), I'm using it with the assumption that it would just return a blank string for content when some part of the lookup fails.

What actually happens:

  • according to PDB, line 341 is where the exception is raised - if the placeholder doesn't exist, it rightly throws Placeholder.DoesNotExist, but this is not handled in a way that allows the tag to be speculatively used. It bubbles all the way up, and, at least when DEBUG is on, will show the 'pretty' error page, if given half the chance.

Addendums:

By proxy, I assume the same problem plagues show_uncached_placeholder_by_id, but a fix here would cover that, too.

I noticed this whilst working on a site running 2.1.3, but looking at the code in develop, I'm guessing it affects the 2.2 line too.

@ojii ojii closed this in 2a46231 Aug 25, 2011

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