Not Found views in Pyramid accept the same predicates as regular views.
config.add_route('wiki', '/wiki/{page}')
@notfound_view_config()
def notfound_view(exc, request):
""" Generic notfound view for the entire site."""
return exc
@notfound_view_config(route_name='wiki')
def wiki_notfound_view(exc, request):
""" Specific notfound for urls matching the wiki pattern."""
return exc
As far as your escaping issue, that's specific to your templating language. In mako you would use ${ msg | n }
and in jinja2 you would use {{ msg | safe }}
to turn off auto-escaping on the string.