本文整理汇总了Python中config.Configuration.hold_policy方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.hold_policy方法的具体用法?Python Configuration.hold_policy怎么用?Python Configuration.hold_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.Configuration
的用法示例。
在下文中一共展示了Configuration.hold_policy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: acquisition_links
# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import hold_policy [as 别名]
def acquisition_links(self, active_license_pool, active_loan, active_hold,
feed, data_source_name, identifier_identifier):
"""Generate a number of <link> tags that enumerate all acquisition methods."""
can_borrow = False
can_fulfill = False
can_revoke = False
can_hold = (
Configuration.hold_policy() ==
Configuration.HOLD_POLICY_ALLOW
)
if active_loan:
can_fulfill = True
can_revoke = True
elif active_hold:
# We display the borrow link even if the patron can't
# borrow the book right this minute.
can_borrow = True
can_revoke = (
not self.circulation or
self.circulation.can_revoke_hold(
active_license_pool, active_hold)
)
else:
# The patron has no existing relationship with this
# work. Give them the opportunity to check out the work
# or put it on hold.
can_borrow = True
# If there is something to be revoked for this book,
# add a link to revoke it.
revoke_links = []
if can_revoke:
url = self.url_for(
'revoke_loan_or_hold', data_source=data_source_name,
identifier=identifier_identifier, _external=True)
kw = dict(href=url, rel=OPDSFeed.REVOKE_LOAN_REL)
revoke_link_tag = E._makeelement("link", **kw)
revoke_links.append(revoke_link_tag)
# Add next-step information for every useful delivery
# mechanism.
borrow_links = []
api = None
if self.circulation:
api = self.circulation.api_for_license_pool(active_license_pool)
if api:
set_mechanism_at_borrow = (
api.SET_DELIVERY_MECHANISM_AT == BaseCirculationAPI.BORROW_STEP)
else:
# This is most likely an open-access book. Just put one
# borrow link and figure out the rest later.
set_mechanism_at_borrow = False
if can_borrow:
# Borrowing a book gives you an OPDS entry that gives you
# fulfillment links.
if set_mechanism_at_borrow:
# The ebook distributor requires that the delivery
# mechanism be set at the point of checkout. This means
# a separate borrow link for each mechanism.
for mechanism in active_license_pool.delivery_mechanisms:
borrow_links.append(
self.borrow_link(
data_source_name, identifier_identifier,
mechanism, [mechanism]
)
)
else:
# The ebook distributor does not require that the
# delivery mechanism be set at the point of
# checkout. This means a single borrow link with
# indirectAcquisition tags for every delivery
# mechanism. If a delivery mechanism must be set, it
# will be set at the point of fulfillment.
borrow_links.append(
self.borrow_link(
data_source_name, identifier_identifier,
None, active_license_pool.delivery_mechanisms
)
)
# Generate the licensing tags that tell you whether the book
# is available.
license_tags = feed.license_tags(
active_license_pool, active_loan, active_hold
)
for link in borrow_links:
for t in license_tags:
link.append(t)
# Add links for fulfilling an active loan.
fulfill_links = []
if can_fulfill:
if active_loan.fulfillment:
# The delivery mechanism for this loan has been
# set. There is only one fulfill link.
fulfill_links.append(
#.........这里部分代码省略.........