summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/events.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/orm/events.py')
-rw-r--r--lib/sqlalchemy/orm/events.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py
index 25211d146..67f6d6431 100644
--- a/lib/sqlalchemy/orm/events.py
+++ b/lib/sqlalchemy/orm/events.py
@@ -925,16 +925,24 @@ class SessionEvents(event.Events):
@classmethod
def _accept_with(cls, target):
- if isinstance(target, orm.ScopedSession):
- if not isinstance(target.session_factory, type) or \
- not issubclass(target.session_factory, orm.Session):
+ if isinstance(target, orm.scoped_session):
+
+ target = target.session_factory
+ if not isinstance(target, orm.sessionmaker) and \
+ (
+ not isinstance(target, type) or
+ not issubclass(target, orm.Session)
+ ):
raise exc.ArgumentError(
- "Session event listen on a ScopedSession "
+ "Session event listen on a scoped_session "
"requires that its creation callable "
- "is a Session subclass.")
- return target.session_factory
+ "is associated with the Session class.")
+
+
+ if isinstance(target, orm.sessionmaker):
+ return target.class_
elif isinstance(target, type):
- if issubclass(target, orm.ScopedSession):
+ if issubclass(target, orm.scoped_session):
return orm.Session
elif issubclass(target, orm.Session):
return target