本文整理匯總了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)))