Example #1
0
    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'])
Example #2
0
File: meta.py Project: FieldDB/clld
    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'])
Example #3
0
def test_format_json():
    from clld.util import format_json

    format_json(date.today())