Skip to content

Commit

Permalink
Add comments to ensure methods don't get dropped
Browse files Browse the repository at this point in the history
These methods are used by social_core
  • Loading branch information
jdavcs committed Feb 22, 2024
1 parent b1ef5c1 commit e50c615
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9526,6 +9526,11 @@ def save(self):

@classmethod
def store(cls, server_url, association):
"""
Create an Association instance
(Required by social_core.storage.AssociationMixin interface)
"""

def get_or_create():
stmt = select(PSAAssociation).filter_by(server_url=server_url, handle=association.handle).limit(1)
assoc = cls.sa_session.scalars(stmt).first()
Expand All @@ -9542,11 +9547,19 @@ def get_or_create():

@classmethod
def get(cls, *args, **kwargs):
"""
Get an Association instance
(Required by social_core.storage.AssociationMixin interface)
"""
stmt = select(PSAAssociation).filter_by(*args, **kwargs)
return cls.sa_session.scalars(stmt).all()

@classmethod
def remove(cls, ids_to_delete):
"""
Remove an Association instance
(Required by social_core.storage.AssociationMixin interface)
"""
stmt = (
delete(PSAAssociation)
.where(PSAAssociation.id.in_(ids_to_delete))
Expand Down Expand Up @@ -9577,6 +9590,9 @@ def save(self):

@classmethod
def get_code(cls, code):
"""
(Required by social_core.storage.CodeMixin interface)
"""
stmt = select(PSACode).where(PSACode.code == code).limit(1)
return cls.sa_session.scalars(stmt).first()

Expand Down Expand Up @@ -9604,6 +9620,10 @@ def save(self):

@classmethod
def use(cls, server_url, timestamp, salt):
"""
Create a Nonce instance
(Required by social_core.storage.NonceMixin interface)
"""
try:
stmt = select(PSANonce).where(server_url=server_url, timestamp=timestamp, salt=salt).limit(1)
return cls.sa_session.scalars(stmt).first()
Expand Down Expand Up @@ -9640,11 +9660,17 @@ def save(self):

@classmethod
def load(cls, token):
"""
(Required by social_core.storage.PartialMixin interface)
"""
stmt = select(PSAPartial).where(PSAPartial.token == token).limit(1)
return cls.sa_session.scalars(stmt).first()

@classmethod
def destroy(cls, token):
"""
(Required by social_core.storage.PartialMixin interface)
"""
partial = cls.load(token)
if partial:
session = cls.sa_session
Expand Down

0 comments on commit e50c615

Please sign in to comment.