How to use the turbojson.jsonify.jsonify.when function in TurboJson

To help you get started, we’ve selected a few TurboJson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedora-infra / python-fedora / fedora / tg / json.py View on Github external
@jsonify.when('isinstance(obj, sqlalchemy.orm.query.Query)')
def jsonify_sa_select_results(obj):
    '''Transform selectresults into lists.

    The one special thing is that we bind the special json_props into each
    descendent.  This allows us to specify a json_props on the toplevel
    query result and it will pass to all of its children.

    :arg obj: sqlalchemy Query object to jsonify
    :Returns: list representation of the Query with each element in it given
        a json_props attributes
    '''
    if 'json_props' in obj.__dict__:
        for element in obj:
            element.json_props = obj.json_props
    return list(obj)
github wesnoth / wesnoth / website / stats.wesnoth.org / wesstats / json.py View on Github external
@jsonify.when('isinstance(obj, Group)')
def jsonify_group(obj):
    result = jsonify_sqlobject( obj )
    result["users"] = [u.user_name for u in obj.users]
    result["permissions"] = [p.permission_name for p in obj.permissions]
    return result
github yt-project / yt / yt / deliverator / deliverator / json.py View on Github external
@jsonify.when('isinstance(obj, User)')
def jsonify_user(obj):
    result = jsonify_sqlobject( obj )
    del result['password']
    result["groups"] = [g.group_name for g in obj.groups]
    result["permissions"] = [p.permission_name for p in obj.permissions]
    return result

TurboJson

Python template plugin that supports JSON

MIT
Latest version published 13 years ago

Package Health Score

42 / 100
Full package analysis

Similar packages