コード例 #1
0
def to_json(things):
    """ 
    If the model/object defines a "to_client" then call it first.
    This way objects can implement the "to_client" interface to return a dictionary
    representation of themselves to be serialized as json.
    """
    return util.js_safety(util.client_dumps(things))
コード例 #2
0
ファイル: canvas_tags.py プロジェクト: bartektomas/canvas
def to_json(things):
    """ 
    If the model/object defines a "to_client" then call it first.
    This way objects can implement the "to_client" interface to return a dictionary
    representation of themselves to be serialized as json.
    """
    return util.js_safety(util.client_dumps(things))
コード例 #3
0
def daily_sticker_activity_json(user):
    activity = None
    if user.kv.has_unseen_daily_free_stickers.get():
        user.kv.has_unseen_daily_free_stickers.delete()
        activity = DailyFreeStickersActivity({
            'reward_stickers': knobs.DAILY_FREE_STICKERS,
        }, actor=user)
        activity = activity_stream_item(activity, user)
    return util.js_safety(util.client_dumps(activity))
コード例 #4
0
def to_escaped_json(things):
    return util.js_safety(util.client_dumps(things), django=False, escape_html=True)