Menu

Commit [r6135]  Maximize  Restore  History

Follow-up to r6126: finally understood what that `del req.chrome` was good for...

This was needed when an error occurs during the rendering of a template.

Here's a summary of what happens:
1. render_template() is called normally, the data is prepared and the chrome data is filled with the initial values obtained from the req callback for chrome, augmented by all calls to add_link, add_scripts etc.
2. right before the template stream is rendered, the req.chrome fields are reset to empty lists, which are also reachable by the `late_links` and `late_scripts` values
3. oops, an internal error while rendering
4. the `req.chrome['links']` are restored so that they can be used while rendering the error template
5. the error handling code does another round of render_template(), this time for the error.html template
6. now the interesting stuff happens if it's an internal error:
- the chrome data gets updated again with the req.chrome, which are at this point still the (empty) "late" lists, and because of that, the jquery.js script is not loaded and the nice interactive stack trace display ''doesn't work'' anymore
- before, when we had the `del req.chrome`, when the chrome data got updated by the req.chrome, this triggered ''another'' call to the req callback for "chrome", i.e. another Chrome.prepare_request, which would add among other things the jquery.js back...

So I think an "obvious" fix of this problem while still preserving the #5594 behavior is to restore the 'scripts' as well at point 4.

Of course, the management of the chrome data could probably be greatly simplified at some point after 0.11.

cboos 2007-11-07

changed /trunk/trac/web/chrome.py
/trunk/trac/web/chrome.py Diff Switch to side-by-side view
Loading...