def __json__(self, req): """ :param req: pyramid Request object. :return: ``dict`` suitable for serialization as JSON. """ cols = [] for om in object_mapper(self).iterate_to_root(): cols.extend(col.key for col in om.local_table.c) return dict((col, format_json(getattr(self, col))) for col in set(cols) if col not in ['created', 'updated', 'polymorphic_type'])
def __json__(self, req): """ :param req: pyramid Request object. :return: ``dict`` suitable for serialization as JSON. """ cols = [] for om in object_mapper(self).iterate_to_root(): cols.extend(col.key for col in om.local_table.c) return dict( (col, format_json(getattr(self, col))) for col in set(cols) if col not in ['created', 'updated', 'polymorphic_type'])
def test_format_json(): from clld.util import format_json format_json(date.today())