コード例 #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
ファイル: test_util.py プロジェクト: Woseseltops/clld
def test_format_json():
    from clld.util import format_json

    format_json(date.today())