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


Python StatementValidator.validate方法代码示例

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


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

示例1: statements_post

# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate [as 别名]
def statements_post(req_dict):
    if req_dict['params'].keys():
        raise ParamError("The post statements request contained unexpected parameters: %s" % ", ".join(req_dict['params'].keys()))

    try:
        validator = StatementValidator(req_dict['body'])
        validator.validate()
    except Exception, e:
        raise BadRequest(e.message)
开发者ID:carvalhomb,项目名称:ADL_LRS,代码行数:11,代码来源:req_validate.py

示例2: statements_post

# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate [as 别名]
def statements_post(req_dict):
    if req_dict['params'].keys() and not ignore_rogue_params:
        raise ParamError("The post statements request contained unexpected parameters: %s" % ", ".join(req_dict['params'].keys()))

    if isinstance(req_dict['body'], basestring):
        req_dict['body'] = convert_to_dict(req_dict['body'])

    try:
        validator = StatementValidator(req_dict['body'])
        validator.validate()
    except Exception, e:
        raise BadRequest(e.message)
开发者ID:frasern,项目名称:ADL_LRS,代码行数:14,代码来源:req_validate.py

示例3: statements_post

# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate [as 别名]
def statements_post(req_dict):
    if req_dict['params'].keys():
        raise ParamError("The post statements request contained unexpected parameters: %s" % ", ".join(
            req_dict['params'].keys()))

    try:
        validator = StatementValidator(req_dict['body'])
        validator.validate()
    except Exception as e:
        raise BadRequest(e.message)
    except ParamError as e:
        raise ParamError(e.message)

    if isinstance(req_dict['body'], dict):
        body = [req_dict['body']]
    else:
        body = req_dict['body']
    validate_body(body, req_dict['auth'], req_dict['headers']['CONTENT_TYPE'])

    return req_dict
开发者ID:adlnet,项目名称:ADL_LRS,代码行数:22,代码来源:req_validate.py

示例4: check_for_existing_statementId

# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate [as 别名]
    # If statement with that ID already exists-raise conflict error
    if check_for_existing_statementId(statement_id):
        raise ParamConflict("A statement with ID %s already exists" % statement_id)
    
    # Set id inside of statement with param id
    if not statement_body_id:
        req_dict['body']['id'] = statement_id

    # If there are no other params-raise param error since nothing else is supplied
    if not check_for_no_other_params_supplied(req_dict['body']):
        raise ParamError("No other params are supplied with statementId.")

    # Validate statement in body
    try:
        validator = StatementValidator(req_dict['body'])
        validator.validate()
    except Exception, e:
        raise BadRequest(e.message)
    except ParamError, e:
        raise ParamError(e.message)
    validate_body([req_dict['body']], req_dict['auth'], req_dict.get('payload_sha2s', None))
    return req_dict

def validate_attachments(attachment_data, payload_sha2s):
    # For each attachment that is in the actual statement
    for attachment in attachment_data:
        # If the attachment data has a sha2 field, must validate it against the payload data
        if 'sha2' in attachment:
            sha2 = attachment['sha2']
            # Check if the sha2 field is a key in the payload dict
            if payload_sha2s:
开发者ID:roadlit,项目名称:lrs,代码行数:33,代码来源:req_validate.py


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