本文整理汇总了Python中StatementValidator.StatementValidator.validate_uri方法的典型用法代码示例。如果您正苦于以下问题:Python StatementValidator.validate_uri方法的具体用法?Python StatementValidator.validate_uri怎么用?Python StatementValidator.validate_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StatementValidator.StatementValidator
的用法示例。
在下文中一共展示了StatementValidator.validate_uri方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: activity_profile_post
# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate_uri [as 别名]
def activity_profile_post(req_dict):
rogueparams = set(req_dict['params']) - set(["activityId", "profileId"])
if rogueparams:
raise ParamError("The post activity profile request contained unexpected parameters: %s" % ", ".join(rogueparams))
validator = StatementValidator()
if 'activityId' in req_dict['params']:
validator.validate_uri(req_dict['params']['activityId'], "activityId param for activity profile")
else:
err_msg = "Error -- activity_profile - method = %s, but activityId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if not 'profileId' in req_dict['params']:
err_msg = "Error -- activity_profile - method = %s, but profileId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if 'headers' not in req_dict or ('CONTENT_TYPE' not in req_dict['headers'] or req_dict['headers']['CONTENT_TYPE'] != "application/json"):
err_msg = "The content type for activity profile POSTs must be application/json"
raise ParamError(err_msg)
if 'body' not in req_dict:
err_msg = "Could not find the profile document"
raise ParamError(err_msg)
req_dict['profile'] = req_dict.pop('raw_body', req_dict.pop('body', None))
return req_dict
示例2: activity_state_put
# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate_uri [as 别名]
def activity_state_put(req_dict):
rogueparams = set(req_dict['params']) - set(["activityId", "agent", "stateId", "registration"])
if rogueparams:
raise ParamError("The put activity state request contained unexpected parameters: %s" % ", ".join(rogueparams))
validator = StatementValidator()
if 'activityId' in req_dict['params']:
validator.validate_uri(req_dict['params']['activityId'], "activityId param for activity state")
else:
err_msg = "Error -- activity_state - method = %s, but activityId parameter is missing.." % req_dict['method']
raise ParamError(err_msg)
if not 'stateId' in req_dict['params']:
err_msg = "Error -- activity_state - method = %s, but stateId parameter is missing.." % req_dict['method']
raise ParamError(err_msg)
if 'registration' in req_dict['params']:
if not validate_uuid(req_dict['params']['registration']):
raise ParamError("%s is not a valid uuid for the registration parameter")
if 'agent' in req_dict['params']:
try:
agent = json.loads(req_dict['params']['agent'])
except Exception, e:
raise ParamError("agent param for activity state is not valid")
validator.validate_agent(agent, "Activity state agent param")
示例3: activity_profile_delete
# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate_uri [as 别名]
def activity_profile_delete(req_dict):
rogueparams = set(req_dict['params']) - set(["activityId", "profileId"])
if rogueparams:
raise ParamError("The delete activity profile request contained unexpected parameters: %s" % ", ".join(rogueparams))
validator = StatementValidator()
if 'activityId' in req_dict['params']:
validator.validate_uri(req_dict['params']['activityId'], "activityId param for activity profile")
else:
err_msg = "Error -- activity_profile - method = %s, but activityId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if not 'profileId' in req_dict['params']:
err_msg = "Error -- activity_profile - method = %s, but profileId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
return req_dict
示例4: activity_profile_get
# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate_uri [as 别名]
def activity_profile_get(req_dict):
rogueparams = set(req_dict['params']) - set(["activityId", "profileId", "since"])
if rogueparams:
raise ParamError("The get activity profile request contained unexpected parameters: %s" % ", ".join(rogueparams))
validator = StatementValidator()
if 'activityId' in req_dict['params']:
validator.validate_uri(req_dict['params']['activityId'], "activityId param for activity profile")
else:
err_msg = "Error -- activity_profile - method = %s, but activityId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if 'since' in req_dict['params']:
try:
parse_datetime(req_dict['params']['since'])
except (Exception, ISO8601Error):
raise ParamError("Since parameter was not a valid ISO8601 timestamp")
return req_dict
示例5: activity_profile_put
# 需要导入模块: from StatementValidator import StatementValidator [as 别名]
# 或者: from StatementValidator.StatementValidator import validate_uri [as 别名]
def activity_profile_put(req_dict):
rogueparams = set(req_dict['params']) - set(["activityId", "profileId"])
if rogueparams:
raise ParamError("The put activity profile request contained unexpected parameters: %s" % ", ".join(rogueparams))
validator = StatementValidator()
if 'activityId' in req_dict['params']:
validator.validate_uri(req_dict['params']['activityId'], "activityId param for activity profile")
else:
err_msg = "Error -- activity_profile - method = %s, but activityId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if not 'profileId' in req_dict['params']:
err_msg = "Error -- activity_profile - method = %s, but profileId parameter missing.." % req_dict['method']
raise ParamError(err_msg)
if 'body' not in req_dict:
err_msg = "Could not find the profile document"
raise ParamError(err_msg)
# Set profile - req_parse converts all request bodies to dict, act profile needs it as string and need to replace single quotes with double quotes
# b/c of quotation issue when using javascript with activity profile
req_dict['profile'] = req_dict.pop('raw_body', req_dict.pop('body', None))
return req_dict