summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-29 18:38:44 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-29 18:38:44 -0500
commit79fc3cdc1b0be99e138580905290823463766944 (patch)
tree0b840795f76853d01be832a6cd851d2026cb3cc7 /lib/sqlalchemy
parent35bfda533ed1546f40a5907dfe87c14c0b71cd0d (diff)
downloadsqlalchemy-79fc3cdc1b0be99e138580905290823463766944.tar.gz
- use class name by itself in flush warnings to prevent overflow of warnings registry
- test suite swaps out warnings.warn with warnings.warn_explicit, to solve warnings registry issue - explicitly disallow functions from inside test.bootstrap, test.lib being interpreted as tests
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/dependency.py8
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py4
-rw-r--r--lib/sqlalchemy/orm/util.py8
-rw-r--r--lib/sqlalchemy/util/langhelpers.py11
4 files changed, 25 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py
index e57b1575a..b9958f775 100644
--- a/lib/sqlalchemy/orm/dependency.py
+++ b/lib/sqlalchemy/orm/dependency.py
@@ -727,9 +727,9 @@ class ManyToOneDP(DependencyProcessor):
child is not None and \
not uowcommit.session._contains_state(child):
util.warn(
- "Child %s not in session, %s "
+ "Object of type %s not in session, %s "
"operation along '%s' won't proceed" %
- (mapperutil.state_str(child), operation, self.prop))
+ (mapperutil.state_class_str(child), operation, self.prop))
return
if clearkeys or child is None:
@@ -1097,9 +1097,9 @@ class ManyToManyDP(DependencyProcessor):
if child is not None and not uowcommit.session._contains_state(child):
if not child.deleted:
util.warn(
- "Child %s not in session, %s "
+ "Object of type %s not in session, %s "
"operation along '%s' won't proceed" %
- (mapperutil.state_str(child), operation, self.prop))
+ (mapperutil.state_class_str(child), operation, self.prop))
return False
self._verify_canload(child)
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 8f7475c4b..db20acb90 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -180,9 +180,9 @@ class UOWTransaction(object):
operation=None, prop=None):
if not self.session._contains_state(state):
if not state.deleted and operation is not None:
- util.warn("Object %s not in session, %s operation "
+ util.warn("Object of type %s not in session, %s operation "
"along '%s' will not proceed" %
- (mapperutil.state_str(state), operation, prop))
+ (mapperutil.state_class_str(state), operation, prop))
return False
if state not in self.states:
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 4661b4b00..23154bd4e 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -595,6 +595,14 @@ def state_str(state):
else:
return '<%s at 0x%x>' % (state.class_.__name__, id(state.obj()))
+def state_class_str(state):
+ """Return a string describing an instance's class via its InstanceState."""
+
+ if state is None:
+ return "None"
+ else:
+ return '<%s>' % (state.class_.__name__, )
+
def attribute_str(instance, attribute):
return instance_str(instance) + "." + attribute
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index 5c12cf67b..68d9709f8 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -684,6 +684,17 @@ def warn_exception(func, *args, **kwargs):
def warn(msg, stacklevel=3):
+ """Issue a warning.
+
+ If msg is a string, :class:`.exc.SAWarning` is used as
+ the category.
+
+ .. note:: This function is swapped out when the test suite
+ runs, with a compatible version that uses
+ warnings.warn_explicit, so that the warnings registry can
+ be controlled.
+
+ """
if isinstance(msg, basestring):
warnings.warn(msg, exc.SAWarning, stacklevel=stacklevel)
else: