diff options
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r-- | lib/sqlalchemy/orm/unitofwork.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index a9808e6ba..673591e8e 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -16,9 +16,7 @@ from sqlalchemy import util, topological from sqlalchemy.orm import attributes, interfaces from sqlalchemy.orm import util as mapperutil from sqlalchemy.orm.util import _state_mapper - -# Load lazily -_state_session = None +session = util.importlater("sqlalchemy.orm", "session") class UOWEventHandler(interfaces.AttributeExtension): """An event handler added to all relationship attributes which handles @@ -34,7 +32,7 @@ class UOWEventHandler(interfaces.AttributeExtension): # process "save_update" cascade rules for when # an instance is appended to the list of another instance - sess = _state_session(state) + sess = session._state_session(state) if sess: prop = _state_mapper(state).get_property(self.key) if prop.cascade.save_update and \ @@ -44,7 +42,7 @@ class UOWEventHandler(interfaces.AttributeExtension): return item def remove(self, state, item, initiator): - sess = _state_session(state) + sess = session._state_session(state) if sess: prop = _state_mapper(state).get_property(self.key) # expunge pending orphans @@ -59,7 +57,7 @@ class UOWEventHandler(interfaces.AttributeExtension): if oldvalue is newvalue: return newvalue - sess = _state_session(state) + sess = session._state_session(state) if sess: prop = _state_mapper(state).get_property(self.key) if newvalue is not None and \ |