本文整理汇总了Python中globaleaks.utils.token.Token.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python Token.serialize方法的具体用法?Python Token.serialize怎么用?Python Token.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.token.Token
的用法示例。
在下文中一共展示了Token.serialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_token
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import serialize [as 别名]
def test_token(self):
st = Token('submission')
st_dict = st.serialize()
self.assertEqual(st_dict['remaining_uses'], Token.MAX_USES)
if st.human_captcha:
self.assertTrue(st.human_captcha.has_key('answer'))
self.assertTrue(isinstance(st.human_captcha['answer'], int))
示例2: post
# 需要导入模块: from globaleaks.utils.token import Token [as 别名]
# 或者: from globaleaks.utils.token.Token import serialize [as 别名]
def post(self):
"""
Request: None
Response: TokenDesc (Token)
Errors: InvalidInputFormat
This API create a Token, a temporary memory only object able to keep
track of the submission. If the system is under stress, complete the
submission will require some actions to be performed before the
submission can be concluded (e.g. hashcash and captchas).
"""
request = self.validate_message(self.request.body, requests.TokenReqDesc)
if request['type'] == 'submission':
if not GLSettings.memory_copy.accept_submissions:
raise errors.SubmissionDisabled
# TODO implement further validations for different token options based on type
# params = self.validate_message(request['params'], requests.TokenParamsSubmissionDesc)
token = Token(request['type'])
self.set_status(201) # Created
self.finish(token.serialize())