mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 11:34:18 +00:00
🔧 Improve and rename SQLAlchemyPDA
This commit is contained in:
parent
c6ac960f2b
commit
98846f5c56
1 changed files with 6 additions and 7 deletions
|
@ -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",
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue