1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 03:24:20 +00:00

🔧 Improve and rename SQLAlchemyPDA

This commit is contained in:
Steffo 2021-04-13 04:30:42 +02:00
parent c6ac960f2b
commit 98846f5c56
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -254,10 +254,10 @@ class ConversationListPDA(PDA, metaclass=abc.ABCMeta):
return full return full
class WithDatabaseSession(ConversationListPDA, metaclass=abc.ABCMeta): class SQLAlchemyPDA(ConversationListPDA, metaclass=abc.ABCMeta):
""" """
A :class:`.ConversationListPDA` with database support provided by :mod:`sqlalchemy`\\ by extending Extends :class:`.ConversationListPDA` with database support provided by :mod:`sqlalchemy`\\ by adding the
:meth:`._conversation_kwargs` with the ``_session`` kwarg. ``_session`` kwarg to the :meth:`._conversation_kwargs`.
""" """
def __init__(self, engine: sqlalchemy.engine.Engine, conversation_kwargs: dict[str, t.Any]): def __init__(self, engine: sqlalchemy.engine.Engine, conversation_kwargs: dict[str, t.Any]):
@ -271,15 +271,14 @@ class WithDatabaseSession(ConversationListPDA, metaclass=abc.ABCMeta):
with self.Session(future=True) as session: with self.Session(future=True) as session:
yield { yield {
"_pda": self,
"_conv": conv,
"_session": session, "_session": session,
**self.conversation_kwargs, **super()._conversation_kwargs(conv=conv),
} }
__all__ = ( __all__ = (
"PDA", "PDA",
"ConversationListPDA", "ConversationListPDA",
"WithDatabaseSession", "SQLAlchemyPDA",
) )