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


Python Configuration.cdn_host方法代码示例

本文整理汇总了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
        )
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:35,代码来源:circulation.py

示例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
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:15,代码来源:opds.py


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