In an exception handler view like this, I'm rendering the 
"hardcoded.template" template in all cases.

@view_config(context=WhateverException, renderer='/path/hardcoded.template')
def whatever_handler(exception, request):
    return {'a': 'b'}

But WhateverException can be raised originally in various views, each using 
their own template.

@view_config(route_name='route1', renderer='/path/route1.template')
def route1(request):
    raise WhateverException()

@view_config(route_name='route2', renderer='/path/route2.template')
def route2(request):
    raise WhateverException()

How can I make the exception handler view choose the template dynamically, 
selecting the template of the view where WhateverException was initially 
raised? (Instead of hardcoding it in the @view_config decorator as I'm 
doing now.)

I think I should probably use something like this (remove renderer argument 
in @view_config and use render_to_response). Is this right?

@view_config(context=WhateverException)
def whatever_handler(exception, request):
    template = # How to get the template e.g. /path/route1.template?

    return render_to_response(template, {'a': 'b'}, request=request)


What's the correct way to get the original template, like 
/path/route1.template, of the view that raised WhateverException?

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to