]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
re-jiggered (yes, thats a technical term) DeprecationWarning into SADeprecationWarnin...
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Jul 2007 20:12:22 +0000 (20:12 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 31 Jul 2007 20:12:22 +0000 (20:12 +0000)
lib/sqlalchemy/logging.py
lib/sqlalchemy/util.py

index 1e62708293f7534846c3b8ec44336a296bfe7d18..20a91d8a802a36dce930042b501514b53edbff20 100644 (file)
@@ -32,11 +32,15 @@ import sys, warnings
 logging = __import__('logging')
 
 
+class SADeprecationWarning(DeprecationWarning):
+    pass
+    
 rootlogger = logging.getLogger('sqlalchemy')
 rootlogger.setLevel(logging.WARN)
 def _logwarning(message, category, filename, lineno, file='ignored'):
     rootlogger.warn(warnings.formatwarning(message, category, filename, lineno))
 warnings.showwarning = _logwarning
+warnings.filterwarnings("once", category=SADeprecationWarning)
 
 default_enabled = False
 def default_logging(name):
index 4925caa69593b27db4524c1d043aa31ced1643e8..28e5083e95186500aec54675cd9b9d79154ee3c6 100644 (file)
@@ -10,7 +10,7 @@ except ImportError:
     import dummy_thread as thread
     import dummy_threading as threading
 
-from sqlalchemy import exceptions
+from sqlalchemy import exceptions, logging
 import md5
 import sys
 import warnings
@@ -542,12 +542,11 @@ class ScopedRegistry(object):
 
 
 def warn_deprecated(msg):
-    warnings.warn(msg, category=DeprecationWarning, stacklevel=3)
+    warnings.warn(logging.SADeprecationWarning(msg), stacklevel=3)
 
 def deprecated(func, add_deprecation_to_docstring=True):
     def func_with_warning(*args, **kwargs):
-        warnings.warn("Call to deprecated function %s" % func.__name__,
-                      category=DeprecationWarning,
+        warnings.warn(logging.SADeprecationWarning("Call to deprecated function %s" % func.__name__),
                       stacklevel=2)
         return func(*args, **kwargs)
     func_with_warning.__name__ = func.__name__