Kind of related trick that paste.exceptions implemented (and may also be in weberror, all adopted from Zope) is if you set the local variable __traceback_info__ to some value, that value would be included in the traceback (that is emailed or whatever). And there are other __traceback_* variables that allow you to do more detailed additions to the report.