本文整理汇总了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)
示例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)
示例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
示例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: