I created a minimal test case. The exception raised by the view is caught
by pyramid_debugtoolbar. The exception raised by the NewRequest callback is
caught but isn't displayed correctly because requests to /_debug_toolbar/*
hit the same exception.
I can fix this by returning early from the callback if PATH_INFO starts
with /_debug_toolbar, but maybe there's a better way.
But this is a bit different from what I'm seeing in my actual app, which is
that the exeption doesn't appear to be caught at all. More investigation
under way...
from waitress import serve
from pyramid.config import Configurator
from pyramid.events import NewRequest
def main(global_config, **settings):
settings['pyramid.includes'] = ['pyramid_debugtoolbar']
config = Configurator(settings=settings)
def callback(event):
something()
#config.add_subscriber(callback, NewRequest)
config.add_route('route', '/route')
config.add_view(view, route_name='route', renderer='string')
app = config.make_wsgi_app()
return app
def view(request):
return xxx
def something():
raise Exception
if __name__ == '__main__':
app = main({})
serve(app)
On Wednesday, February 13, 2013 1:40:00 PM UTC-8, Wyatt Baldwin wrote:
>
> I'm using Pyramid 1.4. pyramid_debugtoolbar is included via the
> pyramid.includes settings. I'm not using any other includes or tweens. The
> subscriber is set up like this:
>
> def main(global_config, *settings):
> config = Configurator(settings=settings)
> def callback(event):
> """Exceptions raised here are not caught by pyramid_debugtoolbar"""
> config.add_subscriber(callback, NewRequest)
> app = config.make_wsgi_app()
> return app
>
>
> On Wednesday, February 13, 2013 11:15:48 AM UTC-8, Michael Merickel wrote:
>>
>> Without more info I can say it's not expected on anything after Pyramid
>> 1.0 where NewRequest subscribers explicitly did not support exceptions.
>>
>>
>> On Wed, Feb 13, 2013 at 12:45 PM, Wyatt Baldwin <[email protected]>wrote:
>>
>>> I have a NewRequest subscriber that's added in main() via
>>> config.add_subscriber(). Exceptions thrown in this subscriber aren't caught
>>> by pyramid_debugtoolbar. Is this behavior expected?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.