本文整理汇总了Python中django.core.signing.TimestampSigner.partition方法的典型用法代码示例。如果您正苦于以下问题:Python TimestampSigner.partition方法的具体用法?Python TimestampSigner.partition怎么用?Python TimestampSigner.partition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.signing.TimestampSigner
的用法示例。
在下文中一共展示了TimestampSigner.partition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: politician_hansard_subscribe
# 需要导入模块: from django.core.signing import TimestampSigner [as 别名]
# 或者: from django.core.signing.TimestampSigner import partition [as 别名]
def politician_hansard_subscribe(request, signed_key):
ctx = {
'key_error': False
}
try:
key = TimestampSigner(salt='alerts_pol_subscribe').unsign(signed_key, max_age=60*60*24*14)
politician_id, _, email = key.partition(',')
pol = get_object_or_404(Politician, id=politician_id)
if not pol.current_member:
raise Http404
user, created = User.objects.get_or_create(email=email)
sub, created = Subscription.objects.get_or_create_by_query(
_generate_query_for_politician(pol), user)
if not sub.active:
sub.active = True
sub.save()
ctx.update(
pol=pol,
title=u'Email alerts for %s' % pol.name
)
except BadSignature:
ctx['key_error'] = True
return render(request, 'alerts/activate.html', ctx)