Pylons / pyramid_layout

Pyramid add-on for managing UI layouts.
Other
24 stars 26 forks source link

Better error handling for missing request and layout manager in add_renderer_globals #3

Closed thehunmonkgroup closed 11 years ago

thehunmonkgroup commented 11 years ago

add_renderer_globals() contains some logic that prevents runtime errors in the case where rendering is done from a script, but I found another case where more general error handling will benefit:

In this case, create_layout_manager() is never called, but add_renderer_globals() is (because the debug toolbar is trying to return the runtime error via a request response, I think).

This is a real pain during development, because the traceback displayed when a runtime error occurs during the building of the context is something like:

  File "lib/python2.6/site-packages/pyramid_layout-0.4-py2.6.egg/pyramid_layout/config.py", line 35, in add_renderer_globals
    layout_manager = request.layout_manager
AttributeError: 'Request' object has no attribute 'layout_manager'

Not a terribly useful in this case. :)

The patch refactors the error handling in add_renderer_globals() in a more general manner, to support both the case of a missing request and a missing layout manager in the request.

chrisrossi commented 11 years ago

Hi thehunmongroup,

Thanks for the bug report. I've checked in a fix that I think addresses your issue on the 'handle-broken-context' branch. This includes a test for the error condition and is more explicit in the code about the condition being checked for. If you agree this addresses your issue, I will go ahead and merge.

Thanks, Chris

thehunmonkgroup commented 11 years ago

Hi Chris,

I've reviewed your fix, and it looks good to me.

Thanks for the quick turnaround time! Any idea when this will make it into an official release? Would be great to not deal with hand-patching the module during our development builds.

Chad