本文整理汇总了Python中deuce.model.Vault.get_vaults_generator方法的典型用法代码示例。如果您正苦于以下问题:Python Vault.get_vaults_generator方法的具体用法?Python Vault.get_vaults_generator怎么用?Python Vault.get_vaults_generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deuce.model.Vault
的用法示例。
在下文中一共展示了Vault.get_vaults_generator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_get
# 需要导入模块: from deuce.model import Vault [as 别名]
# 或者: from deuce.model.Vault import get_vaults_generator [as 别名]
def on_get(self, req, resp):
# NOTE(TheSriram): get_param(param) automatically returns None
# if param is not present
inmarker = req.get_param('marker')
limit = req.get_param_as_int('limit') if req.get_param_as_int('limit') else \
conf.api_configuration.default_returned_num
vaultlist = Vault.get_vaults_generator(
inmarker, limit + 1)
response = list(vaultlist)
if not response:
resp.body = json.dumps([])
# Note: the list may not actually be truncated
truncated = len(response) == limit + 1
outmarker = response.pop() if truncated else None
# Set x-next-batch resp header.
if outmarker:
query_args = {'marker': outmarker}
query_args['limit'] = limit
returl = set_qs_on_url(req.url, query_args)
resp.set_header(name="X-Next-Batch", value=returl)
# Set return json for vault URLs.
p = urlparse(req.url)
resp.body = json.dumps(dict(six.moves.map(lambda vaultname:
(vaultname, {"url": p.scheme +
'://' + p.netloc + p.path + '/' + vaultname}), response)))