本文整理汇总了Python中cache_nuggets.lib.Token.save方法的典型用法代码示例。如果您正苦于以下问题:Python Token.save方法的具体用法?Python Token.save怎么用?Python Token.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_nuggets.lib.Token
的用法示例。
在下文中一共展示了Token.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _mini_manifest
# 需要导入模块: from cache_nuggets.lib import Token [as 别名]
# 或者: from cache_nuggets.lib.Token import save [as 别名]
def _mini_manifest(addon, version_id, token=None):
if not addon.is_packaged:
raise http.Http404
version = get_object_or_404(addon.versions, pk=version_id)
file_ = version.all_files[0]
manifest = addon.get_manifest_json(file_)
package_path = absolutify(
reverse('reviewers.signed', args=[addon.app_slug, version.id]))
if token:
# Generate a fresh token.
token = Token(data={'app_id': addon.id})
token.save()
package_path = urlparams(package_path, token=token.token)
data = {
'name': manifest['name'],
'version': version.version,
'size': file_.size,
'release_notes': version.releasenotes,
'package_path': package_path,
}
for key in ['developer', 'icons', 'locales']:
if key in manifest:
data[key] = manifest[key]
return json.dumps(data, cls=JSONEncoder)
示例2: redirect
# 需要导入模块: from cache_nuggets.lib import Token [as 别名]
# 或者: from cache_nuggets.lib.Token import save [as 别名]
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)
示例3: post
# 需要导入模块: from cache_nuggets.lib import Token [as 别名]
# 或者: from cache_nuggets.lib.Token import save [as 别名]
def post(self, request, pk, *args, **kwargs):
app = self.get_object()
token = Token(data={'app_id': app.id})
token.save()
log.info('Generated token on app:%s for user:%s' % (
app.id, request.amo_user.id))
return Response({'token': token.token})
示例4: redirect
# 需要导入模块: from cache_nuggets.lib import Token [as 别名]
# 或者: from cache_nuggets.lib.Token import save [as 别名]
def redirect(request, viewer, key):
new = Token(data=[viewer.file.id, key])
new.save()
url = reverse('files.serve', args=[viewer, key])
url = urlparams(url, token=new.token)
return http.HttpResponseRedirect(url)