Пример #1
0
Файл: meta.py Проект: clld/clld
    def __json__(self, req):
        """Custom JSON serialization of an object.

        :param req: pyramid Request object.
        :return: ``dict`` suitable for serialization as JSON.
        """
        exclude = {'active', 'version', 'created', 'updated', 'polymorphic_type'}
        cols = [
            col.key for om in inspect(self).mapper.iterate_to_root()
            for col in om.local_table.c
            if col.key not in exclude and not exclude.add(col.key)]
        return {col: jsonlib.format(getattr(self, col)) for col in cols}
Пример #2
0
    def __json__(self, req):
        """Custom JSON serialization of an object.

        :param req: pyramid Request object.
        :return: ``dict`` suitable for serialization as JSON.
        """
        exclude = {'active', 'version', 'created', 'updated', 'polymorphic_type'}
        cols = [
            col.key for om in inspect(self).mapper.iterate_to_root()
            for col in om.local_table.c
            if col.key not in exclude and not exclude.add(col.key)]
        return {col: jsonlib.format(getattr(self, col)) for col in cols}
Пример #3
0
def test_format_json():
    format(date.today())
    assert format(5) == 5
Пример #4
0
    def test_format_json(self):
        from clldutils.jsonlib import format

        format(date.today())
        self.assertEquals(format(5), 5)