import py class FakeDict(dict): def __init__(self, **kwargs): self.dict = kwargs def __getitem__(self, key): return self.dict.get(key, '') __marker__ = [] def get(self, key, default=__marker__): ret = self.dict.get(key, default) if ret == __marker__: return '' return ret def errorhandler(self, request, exc, e, tb): from templess.templess import elnode, textnode h1 = elnode('h1', {}, None, None) textnode('%s - %s' % (exc, e), h1) pre = elnode('pre', {}, None, None) textnode('\n'.join(py.std.traceback.format_tb(tb)), pre) # note that we don't return a normal dict, instead we return something # that returns an empty string on access to keys that are not available return FakeDict(title = '%s - %s' % (exc, e), body = [h1, pre])