summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-13 13:19:36 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-13 13:19:36 -0500
commitaf4285e6adf2a052ce985f9d3d97cc89778fca96 (patch)
tree56364c556828d5c7e103e57a82ef82e41d603fb9 /lib/sqlalchemy/orm/unitofwork.py
parent5400ea2c1e2c605843255f5eb15b5ce1d8fba025 (diff)
downloadsqlalchemy-af4285e6adf2a052ce985f9d3d97cc89778fca96.tar.gz
- move inline "import" statements to use new "util.importlater()" construct. cuts
down on clutter, timeit says there's a teeny performance gain, at least where the access is compared against attr.subattr. these aren't super-critical calls anyway - slight inlining in _class_to_mapper
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py10
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 \