• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util_http.get_optional函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中squeakspace.common.util_http.get_optional函数的典型用法代码示例。如果您正苦于以下问题:Python get_optional函数的具体用法?Python get_optional怎么用?Python get_optional使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    message_id = ht.get_required(query, 'message_id')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    passphrase = ht.get_optional(query, 'passphrase')
    to_key_passphrase = ht.get_optional(query, 'to_key_passphrase')
    decrypt_message = ht.convert_bool(ht.get_optional(query, 'decrypt_message'), 'decrypt_message')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp, validation = db.read_message(c, user_id, session_id, node_name, message_id,
                                           public_key_hash, passphrase,
                                           to_key_passphrase, decrypt_message)

        raise ht.ok_json({'status' : 'ok',
                          'resp' : resp,
                          'validation' : validation})
        
    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:31,代码来源:message.py


示例2: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp")
    node_name = ht.get_required(query, "node_name")
    to_user = ht.get_required(query, "to_user")
    from_user = ht.get_optional(query, "from_user")
    from_user_key_hash = ht.get_optional(query, "from_user_key_hash")
    from_user_key_sig = ht.get_optional(query, "from_user_key_sig")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        max_message_size = db.read_max_message_size(
            c, timestamp, node_name, to_user, from_user, from_user_key_hash, from_user_key_sig
        )

        raise ht.ok_json({"status": "ok", "max_message_size": max_message_size})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:25,代码来源:max_message_size.py


示例3: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    to_user = ht.get_required(query, 'to_user')
    from_user_key_hash = ht.get_optional(query, 'from_user_key_hash')
    passphrase = ht.get_optional(query, 'passphrase')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.query_message_access(c, user_id, session_id, node_name, to_user, from_user_key_hash, passphrase)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp})
        
    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.commit(conn)
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:27,代码来源:query_message_access.py


示例4: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    method  = ht.get_required(query, 'method')
    password  = ht.get_optional(query, 'password')
    public_key_hash  = ht.get_optional(query, 'public_key_hash')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.set_password(c, user_id, session_id, method, password, public_key_hash)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:25,代码来源:password.py


示例5: delete_handler

def delete_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    post_id = ht.get_required(query, 'post_id')
    delete_signature = ht.get_optional(query, 'delete_signature')
    proof_of_work = ht.get_optional(query, 'proof_of_work')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.delete_post(c, timestamp, node_name, group_id, owner_id, post_id, proof_of_work, delete_signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:elpassassin,项目名称:squeakspace,代码行数:25,代码来源:post.py


示例6: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    post_id = ht.get_required(query, 'post_id')
    passphrase = ht.get_optional(query, 'passphrase')
    decrypt_post = ht.convert_bool(ht.get_optional(query, 'decrypt_post'), 'decrypt_post')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp, validation = db.read_post(c,
                user_id, session_id, node_name, group_id, owner_id, post_id,
                passphrase, decrypt_post)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp, 'validation' : validation})
        
    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:29,代码来源:post.py


示例7: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, "timestamp"), "timestamp")
    node_name = ht.get_required(query, "node_name")
    group_id = ht.get_required(query, "group_id")
    owner_id = ht.get_required(query, "owner_id")
    key_use = ht.get_required(query, "key_use")
    key_type = ht.get_optional(query, "key_type")
    pub_key = ht.get_optional(query, "pub_key")
    public_key_hash = ht.get_required(query, "public_key_hash")
    signature = ht.get_required(query, "signature")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_group_key(
            c, timestamp, node_name, group_id, owner_id, key_use, key_type, pub_key, public_key_hash, signature
        )
        db.commit(conn)

        raise ht.ok_json({"status": "ok"})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:29,代码来源:group_key.py


示例8: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    new_size = ht.convert_int(ht.get_optional(query, 'new_size'), 'new_size')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    passphrase = ht.get_optional(query, 'passphrase')


    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.change_max_message_size(c,
                user_id, session_id, node_name, new_size, public_key_hash, passphrase)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:28,代码来源:max_message_size.py


示例9: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, "user_id")
    session_id = ht.get_required_cookie(cookies, "session_id")

    node_name = ht.get_required(query, "node_name")
    group_id = ht.get_required(query, "group_id")
    key_use = ht.get_required(query, "key_use")
    group_key_hash = ht.get_optional(query, "group_key_hash")
    public_key_hash = ht.get_required(query, "public_key_hash")
    passphrase = ht.get_optional(query, "passphrase")

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.change_group_key(
            c, user_id, session_id, node_name, group_id, key_use, group_key_hash, public_key_hash, passphrase
        )

        db.commit(conn)

        raise ht.ok_json({"status": "ok", "resp": resp})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:31,代码来源:group_key.py


示例10: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time')
    end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time')
    max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records')
    order = ht.get_optional(query, 'order')
    passphrase = ht.get_optional(query, 'passphrase')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.read_post_list(c, user_id, session_id,
                                 node_name, group_id, owner_id,
                                 start_time, end_time, max_records, order, passphrase)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp})
        
    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:31,代码来源:post_list.py


示例11: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    key_type = ht.get_required(query, 'key_type')
    key_parameters  = ht.get_optional(query, 'key_parameters')
    revoke_date = ht.get_optional(query, 'revoke_date')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        public_key_hash = db.generate_private_key(
                c, user_id, session_id, key_type, key_parameters, revoke_date)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok', 'public_key_hash' : public_key_hash})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:26,代码来源:gen_key.py


示例12: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    new_size = ht.convert_int(ht.get_required(query, 'new_size'), 'new_size')
    user_class = ht.get_optional(query, 'user_class')
    auth_token = ht.get_optional(query, 'auth_token')

    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.change_user_quota(c,
                timestamp, node_name, user_id, new_size,
                user_class, auth_token,
                public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:30,代码来源:user_quota.py


示例13: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    from_user_key_hash = ht.get_optional(query, 'from_user_key_hash')
    access = ht.get_required(query, 'access')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.set_message_access(c,
                timestamp, node_name, user_id, from_user_key_hash, access,
                public_key_hash, signature)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:27,代码来源:message_access.py


示例14: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    url = ht.get_required(query, 'url')
    real_node_name = ht.get_required(query, 'real_node_name')
    fingerprint = ht.get_optional(query, 'fingerprint')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.set_node_addr(c, user_id, session_id, node_name, url, real_node_name, fingerprint)

        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:27,代码来源:node_addr.py


示例15: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    node_name = ht.get_required(query, 'node_name')
    use = ht.get_required(query, 'use')
    access = ht.get_required(query, 'access')
    timestamp = ht.get_optional(query, 'timestamp')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.set_local_group_access(c, user_id, session_id, group_id, owner_id, node_name, use, access, timestamp)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:28,代码来源:group_access.py


示例16: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    public_key_hash  = ht.get_required(query, 'public_key_hash')
    passphrase = ht.get_required(query, 'passphrase')
    expire_time = ht.convert_int(ht.get_optional(query, 'expire_time'), 'expire_time')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        db.cache_passphrase(c, user_id, session_id, public_key_hash, passphrase, expire_time)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok'})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:elpassassin,项目名称:squeakspace,代码行数:25,代码来源:passphrase.py


示例17: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    owner_id = ht.get_required(query, 'owner_id')
    use = ht.get_required(query, 'use')
    passphrase = ht.get_optional(query, 'passphrase')
 
    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.read_group_access(c, user_id, session_id, node_name, group_id, owner_id, use, passphrase)

        db.commit(conn)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp})
        
    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:28,代码来源:group_access.py


示例18: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)

    timestamp = ht.convert_int(ht.get_required(query, 'timestamp'), 'timestamp')
    node_name = ht.get_required(query, 'node_name')
    user_id = ht.get_required(query, 'user_id')
    to_user_key = ht.get_optional(query, 'to_user_key')
    from_user = ht.get_optional(query, 'from_user')
    from_user_key = ht.get_optional(query, 'from_user_key')
    start_time = ht.convert_int(ht.get_optional(query, 'start_time'), 'start_time')
    end_time = ht.convert_int(ht.get_optional(query, 'end_time'), 'end_time')
    max_records = ht.convert_int(ht.get_optional(query, 'max_records'), 'max_records')
    order = ht.get_optional(query, 'order')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    signature = ht.get_required(query, 'signature')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        message_list = db.read_message_list(c, timestamp, node_name, user_id,
                                            to_user_key, from_user, from_user_key,
                                            start_time, end_time, max_records, order,
                                            public_key_hash, signature)

        raise ht.ok_json({'status' : 'ok', 'message_list' : message_list})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:32,代码来源:message_list.py


示例19: post_handler

def post_handler(environ):

    query = ht.parse_post_request(environ)
    cookies = ht.parse_cookies(environ)

    user_id = ht.get_required_cookie(cookies, 'user_id')
    session_id = ht.get_required_cookie(cookies, 'session_id')

    node_name = ht.get_required(query, 'node_name')
    group_id = ht.get_required(query, 'group_id')
    post_access = ht.get_required(query, 'post_access')
    read_access = ht.get_required(query, 'read_access')
    delete_access = ht.get_required(query, 'delete_access')
    posting_key_hash = ht.get_optional(query, 'posting_key_hash')
    reading_key_hash = ht.get_optional(query, 'reading_key_hash')
    delete_key_hash = ht.get_optional(query, 'delete_key_hash')
    quota_allocated = ht.convert_int(ht.get_required(query, 'quota_allocated'), 'quota_allocated')
    when_space_exhausted = ht.get_required(query, 'when_space_exhausted')
    max_post_size = ht.convert_int(ht.get_optional(query, 'max_post_size'), 'max_post_size')
    public_key_hash = ht.get_required(query, 'public_key_hash')
    passphrase = ht.get_optional(query, 'passphrase')

    conn = db.connect(config.db_path)
    try:
        c = db.cursor(conn)
        resp = db.create_group(c, user_id, session_id,
                               node_name, group_id,
                               post_access, read_access, delete_access,
                               posting_key_hash, reading_key_hash, delete_key_hash,
                               quota_allocated, when_space_exhausted,
                               max_post_size,
                               public_key_hash, passphrase)
        db.commit(conn)

        raise ht.ok_json({'status' : 'ok', 'resp' : resp})

    except ex.SqueakException as e:
        raise ht.convert_squeak_exception(e)

    finally:
        db.close(conn)
开发者ID:eek6,项目名称:squeakspace,代码行数:41,代码来源:group.py


示例20: get_handler

def get_handler(environ):

    query = ht.parse_get_request(environ)

    node_name = ht.get_required(query, 'node_name')
    user_class = ht.get_optional(query, 'user_class')

    quota_available = db.get_quota_available(node_name, user_class)

    raise ht.ok_json(
            {'status' : 'ok',
             'quota_available' : quota_available})
开发者ID:eek6,项目名称:squeakspace,代码行数:12,代码来源:quota_available.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util_http.get_required函数代码示例发布时间:2022-05-27
下一篇:
Python util_http.dispatch_on_method函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap