Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions warehouse/macaroons/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import pymacaroons

from pymacaroons.exceptions import MacaroonDeserializationException
from sqlalchemy.exc import NoResultFound
from sqlalchemy.orm import joinedload
from zope.interface import implementer

Expand Down Expand Up @@ -199,16 +198,12 @@ def get_macaroon_by_description(self, user_id, description):

Returns None if the user doesn't have a macaroon with this description.
"""
try:
dm = (
self.db.query(Macaroon)
.options(joinedload("user"))
.filter(Macaroon.description == description)
.filter(Macaroon.user_id == user_id)
.one()
)
except NoResultFound:
return None
dm = (
self.db.query(Macaroon)
.filter(Macaroon.description == description)
.filter(Macaroon.user_id == user_id)
.one_or_none()
)

return dm

Expand Down