예제 #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'])
예제 #2
0
파일: meta.py 프로젝트: 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'])
예제 #3
0
def test_format_json():
    from clld.util import format_json

    format_json(date.today())