Skip to content

Commit

Permalink
Fix format sweep script by ensuring all operations within the context…
Browse files Browse the repository at this point in the history
… manager are performed on the same session.
  • Loading branch information
dbernstein committed Dec 18, 2024
1 parent ff63d23 commit 6b966e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/palace/manager/api/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def apply(
self.drm_scheme,
self.rights_uri,
self.resource,
db=_db,
)
loan.fulfillment = lpdm
return lpdm
Expand Down
1 change: 1 addition & 0 deletions src/palace/manager/core/metadata_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ def apply(
format.drm_scheme,
format.rights_uri or self.default_rights_uri,
resource,
db=_db,
)
new_lpdms.append(lpdm)

Expand Down
8 changes: 7 additions & 1 deletion src/palace/manager/sqlalchemy/model/licensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ def set(
drm_scheme,
rights_uri,
resource=None,
db=None,
) -> LicensePoolDeliveryMechanism:
"""Register the fact that a distributor makes a title available in a
certain format.
Expand All @@ -1571,7 +1572,12 @@ def set(
:param resource: A Resource representing the book itself in
a freely redistributable form.
"""
_db = Session.object_session(data_source)

if db:
_db = db
else:
_db = Session.object_session(data_source)

delivery_mechanism, ignore = DeliveryMechanism.lookup(
_db, content_type, drm_scheme
)
Expand Down

0 comments on commit 6b966e3

Please sign in to comment.