Fix leaking data between TemplateHooks and add sandboxing.

Review Request #5761 — Created May 1, 2014 and submitted

Information

Djblets
master
8297cc7...

Reviewers

TemplateHooks could easily leak data into the main context when
rendering, overriding variables provided by other contexts. While
TemplateHook tries to push/pop, subclasses can always override and
forget to do so. They can also potentially raise an exception, breaking
the rendering of the page.

To work around all this, we now push/pop in template_hook_point, to
prevent any leakage, and catch exceptions to help sandbox.

Unit tests pass.

First saw this issue when rbmotd's custom TemplateHook was writing directly
into the context, causing issues with the Power Pack config page. After this
change, it all worked properly.

Description From Last Updated

This doesn't need to be in a "finally" block, it can just be another line after the try/except.

daviddavid
david
  1. This should probably go into release-0.7.x

    1. The design of TemplateHook is different in 0.7.x. I'd need to basically port this change. Going to get this in as-is to master first.

  2. Show all issues

    This doesn't need to be in a "finally" block, it can just be another line after the try/except.

  3. 
      
chipx86
david
  1. Ship It!

  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (d0de634)