本文整理汇总了Python中karl.views.api.TemplateAPI.set_status_message方法的典型用法代码示例。如果您正苦于以下问题:Python TemplateAPI.set_status_message方法的具体用法?Python TemplateAPI.set_status_message怎么用?Python TemplateAPI.set_status_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karl.views.api.TemplateAPI
的用法示例。
在下文中一共展示了TemplateAPI.set_status_message方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from karl.views.api import TemplateAPI [as 别名]
# 或者: from karl.views.api.TemplateAPI import set_status_message [as 别名]
def __call__(self):
tapi = TemplateAPI(self.context, self.request, 'Trash')
if self.error is None:
self.fill_deleted()
else:
tapi.set_status_message(unicode(self.error))
return {'api': tapi, 'deleted': self.deleted}
示例2: configure_twofactor_view
# 需要导入模块: from karl.views.api import TemplateAPI [as 别名]
# 或者: from karl.views.api.TemplateAPI import set_status_message [as 别名]
def configure_twofactor_view(context, request):
page_title = "Profile: %s" % context.title
api = TemplateAPI(context, request, page_title)
tf = TwoFactor(context, request)
if (not tf.enabled or not tf.phone_factor_enabled or
not authenticated_userid(request) == context.__name__):
return HTTPFound(request.resource_url(context))
form = 'number'
number = ''
if request.method == 'POST':
number = request.POST.get('phonenumber', '')
if 'form.verifyemail.submitted' in request.POST:
number = ''.join(n for n in number if n in string.digits)
if len(number) == 10:
context.two_factor_phone = number
code = context._two_factor_verify_code = make_random_code(6)
msg = "%s phone verification code: %s" % (
get_setting(context, 'title'),
code)
tf.send_text_to_number(number, msg)
api.set_status_message('Verification code sent to phone number: %s' % number)
form = 'verify'
else:
api.set_status_message('Invalid phone number')
elif 'form.verifycode.submitted' in request.POST:
form = 'verify'
code = request.POST['code']
if code == context._two_factor_verify_code:
context._two_factor_verify_code = ''
context.two_factor_verified = True
form = 'success'
else:
api.set_status_message('Invalid verification code')
return dict(
api=api,
form=form,
number=number,
context=context)