当前位置: 首页>>代码示例>>Python>>正文


Python Tools.setData方法代码示例

本文整理汇总了Python中tools.Tools.setData方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.setData方法的具体用法?Python Tools.setData怎么用?Python Tools.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tools.Tools的用法示例。


在下文中一共展示了Tools.setData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: site_subscribe

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import setData [as 别名]
def site_subscribe():
    if g.user:
        return jsonify({"error": "already loggued"}), 403
    if not "email" in request.form and len(request.form["email"]) > 0:
        return jsonify({"error": "email not present"}), 400
    email = request.form["email"]
    if not "password" in request.form and len(request.form["password"]) > 0:
        return jsonify({"error": "password not present"}), 400
    password = request.form["password"]
    r = get_db()
    if len(Tools.getData(r, "user_" + email)) > 0:
        return jsonify({"error": "user already exists"}), 400
    Tools.setData(r, "user_" + email, {"email": email, "password": hashlib.sha1(password).hexdigest()})
    return jsonify({"subscribed": "true"})
开发者ID:steven-martins,项目名称:trakkar-py,代码行数:16,代码来源:main.py

示例2: phone_fetchcode

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import setData [as 别名]
def phone_fetchcode():
    if not "id" in request.form:
        return jsonify({"error": "id not present"}), 400
    if not "key" in request.form:
        return jsonify({"error": "key not present"}), 400
    _id = request.form['id']
    _key = request.form['key']
    # + key pour signer WS
    r = get_db()
    key = Tools.generateSimpleHash()
    while r.hexists("waiting_devices", key):
        key = generateSimpleHash()          
    r.hset("waiting_devices", key, _id)
    print("fetchcode: device_" + _id + ", secret: " + _key + ", 6digits" + key)
    # rajouter un expire
    Tools.setData(r, "device_" + _id, {"secret": _key, "6digits": key})
    return jsonify({"hash": key})
开发者ID:steven-martins,项目名称:trakkar-py,代码行数:19,代码来源:main.py

示例3: site_removeDevices

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import setData [as 别名]
def site_removeDevices():
    if not g.user:
        return jsonify({"error": "not loggued"}), 403
    r = get_db()
    obj = Tools.getData(r, "user_" + g.user)
    if len(obj) == 0:
        return jsonify({"error": "internal error, user object is empty"}), 500
    if not "id" in request.form:
        return jsonify({"error": "id not present"}), 400
    _id = request.form['id']
    device = Tools.getData(r, "device_" + _id)
    if len(device) == 0:
        return jsonify({"error": "internal error, device object is empty"}), 500
    if "owner" in device:
        device.pop("owner", None)
        Tools.setData(r, "device_" + _id, device)
    if "devices" in obj:
        if obj["devices"].count(_id) > 0:
            obj["devices"].remove(_id)
            Tools.setData(r, "user_" + g.user, obj)
    return jsonify({"removed": "true", "id": _id})
开发者ID:steven-martins,项目名称:trakkar-py,代码行数:23,代码来源:main.py

示例4: site_addDevices

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import setData [as 别名]
def site_addDevices():
    if not g.user:
        return jsonify({"error": "not loggued"}), 403
    r = get_db()
    obj = Tools.getData(r, "user_" + g.user)
    if len(obj) == 0:
        return jsonify({"error": "internal error, user object is empty"}), 500
    if not "code" in request.form:
        return jsonify({"error": "code not present"}), 400
    _6digits = request.form['code']
    if not r.hexists("waiting_devices", _6digits):
        return jsonify({"error": "device not known"}), 404
    _id = r.hget("waiting_devices", _6digits)
    device = Tools.getData(r, "device_" + _id)
    if len(device) == 0:
        return jsonify({"error": "internal error, device object is empty"}), 500
    if not "devices" in obj:
        obj["devices"] = []
    obj["devices"].append(_id)
    device["owner"] = obj["email"]
    Tools.setData(r, "device_" + _id, device)
    Tools.setData(r, "user_" + g.user, obj)
    return jsonify({"added": "true", "id": _id})
开发者ID:steven-martins,项目名称:trakkar-py,代码行数:25,代码来源:main.py


注:本文中的tools.Tools.setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。