本文整理汇总了Python中config.Configuration.cdn_host方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.cdn_host方法的具体用法?Python Configuration.cdn_host怎么用?Python Configuration.cdn_host使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.cdn_host方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fulfill_open_access
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import cdn_host [as 别名]
def fulfill_open_access(self, licensepool, delivery_mechanism):
# Keep track of a default way to fulfill this loan in case the
# patron's desired delivery mechanism isn't available.
fulfillment = None
for lpdm in licensepool.delivery_mechanisms:
if not (lpdm.resource and lpdm.resource.representation
and lpdm.resource.representation.url):
# We don't actually know how to deliver this
# allegedly open-access book.
continue
if lpdm.delivery_mechanism == delivery_mechanism:
# We found it! This is how the patron wants
# the book to be delivered.
fulfillment = lpdm
break
elif not fulfillment:
# This will do in a pinch.
fulfillment = lpdm
if not fulfillment:
# There is just no way to fulfill this loan.
raise NoOpenAccessDownload()
rep = fulfillment.resource.representation
cdn_host = Configuration.cdn_host(Configuration.CDN_OPEN_ACCESS_CONTENT)
content_link = cdnify(rep.url, cdn_host)
media_type = rep.media_type
return FulfillmentInfo(
identifier_type=licensepool.identifier.type,
identifier=licensepool.identifier.identifier,
content_link=content_link, content_type=media_type, content=None,
content_expires=None
)
示例2: open_access_link
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import cdn_host [as 别名]
def open_access_link(self, lpdm):
cdn_host = Configuration.cdn_host(Configuration.CDN_OPEN_ACCESS_CONTENT)
url = cdnify(lpdm.resource.url, cdn_host)
kw = dict(rel=OPDSFeed.OPEN_ACCESS_REL, href=url)
rep = lpdm.resource.representation
if rep and rep.media_type:
kw['type'] = rep.media_type
link_tag = AcquisitionFeed.link(**kw)
always_available = E._makeelement(
"{%s}availability" % opds_ns, status="available"
)
link_tag.append(always_available)
return link_tag