当前位置: 首页>>代码示例>>Python>>正文


Python utils.Token类代码示例

本文整理汇总了Python中amo.utils.Token的典型用法代码示例。如果您正苦于以下问题:Python Token类的具体用法?Python Token怎么用?Python Token使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Token类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: redirect

def redirect(request, viewer, key):
    new = Token(data=[viewer.file.id, key])
    new.save()
    url = '%s%s?token=%s' % (settings.STATIC_URL,
                             reverse('files.serve', args=[viewer, key]),
                             new.token)
    return http.HttpResponseRedirect(url)
开发者ID:LucianU,项目名称:zamboni,代码行数:7,代码来源:views.py

示例2: redirect

def redirect(request, viewer, key):
    new = Token(data=[viewer.file.id, key])
    new.save()
    url = urljoin(settings.STATIC_URL,
                  reverse('mkt.files.serve', args=[viewer, key]))
    url = urlparams(url, token=new.token)
    return http.HttpResponseRedirect(url)
开发者ID:dimonov,项目名称:zamboni,代码行数:7,代码来源:views.py

示例3: wrapper

 def wrapper(request, file_id, key, *args, **kw):
     viewer = FileViewer(get_object_or_404(File, pk=file_id))
     token = request.GET.get('token')
     if not token:
         log.error('Denying access to %s, no token.' % viewer.file.id)
         raise PermissionDenied
     if not Token.valid(token, [viewer.file.id, key]):
         log.error('Denying access to %s, token invalid.' % viewer.file.id)
         raise PermissionDenied
     return func(request, viewer, key, *args, **kw)
开发者ID:darkwing,项目名称:zamboni,代码行数:10,代码来源:decorators.py

示例4: wrapper

 def wrapper(request, file_id, key, *args, **kw):
     viewer = FileViewer(get_object_or_404(File, pk=file_id))
     token = request.GET.get('token')
     if not token:
         log.error('Denying access to %s, no token.' % viewer.file.id)
         return http.HttpResponseForbidden()
     if not Token.valid(token, [viewer.file.id, key]):
         log.error('Denying access to %s, token invalid.' % viewer.file.id)
         return http.HttpResponseForbidden()
     return func(request, viewer, key, *args, **kw)
开发者ID:21echoes,项目名称:zamboni,代码行数:10,代码来源:decorators.py

示例5: wrapper

 def wrapper(request, file_id, key, *args, **kw):
     viewer = FileViewer(get_object_or_404(File, pk=file_id), is_webapp=kwargs.get("is_webapp", False))
     token = request.GET.get("token")
     if not token:
         log.error("Denying access to %s, no token." % viewer.file.id)
         raise PermissionDenied
     if not Token.valid(token, [viewer.file.id, key]):
         log.error("Denying access to %s, token invalid." % viewer.file.id)
         raise PermissionDenied
     return func(request, viewer, key, *args, **kw)
开发者ID:rhelmer,项目名称:zamboni,代码行数:10,代码来源:decorators.py

示例6: test_token_well_formed

 def test_token_well_formed(self):
     new = Token("some badly formed token")
     assert not new.well_formed()
开发者ID:rtilder,项目名称:zamboni,代码行数:3,代码来源:test_helpers.py

示例7: test_token_bad_ip_invalid

 def test_token_bad_ip_invalid(self):
     new = Token(data="127.0.0.1")
     new.save()
     assert not Token.pop(new.token, "255.255.255.0")
     assert Token.pop(new.token, "127.0.0.1")
开发者ID:rtilder,项目名称:zamboni,代码行数:5,代码来源:test_helpers.py

示例8: test_token_no_ip_invalid

 def test_token_no_ip_invalid(self):
     new = Token()
     assert not Token.valid(new.token, "255.255.255.0")
开发者ID:rtilder,项目名称:zamboni,代码行数:3,代码来源:test_helpers.py

示例9: test_token_ip

 def test_token_ip(self):
     new = Token(data="127.0.0.1")
     new.save()
     assert Token.valid(new.token, "127.0.0.1")
开发者ID:rtilder,项目名称:zamboni,代码行数:4,代码来源:test_helpers.py

示例10: test_token_fails

 def test_token_fails(self):
     assert not Token.pop("some-random-token")
开发者ID:rtilder,项目名称:zamboni,代码行数:2,代码来源:test_helpers.py

示例11: test_token_valid

 def test_token_valid(self):
     new = Token()
     new.save()
     assert Token.valid(new.token)
开发者ID:rtilder,项目名称:zamboni,代码行数:4,代码来源:test_helpers.py

示例12: test_token_pop

 def test_token_pop(self):
     new = Token()
     new.save()
     assert Token.pop(new.token)
     assert not Token.pop(new.token)
开发者ID:rtilder,项目名称:zamboni,代码行数:5,代码来源:test_helpers.py


注:本文中的amo.utils.Token类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。