[Checkins] SVN: zope.deprecation/trunk/ Removed import cycle for ``__show__``.

Tres Seaver tseaver at palladion.com
Sat Jul 4 12:44:55 EDT 2009


Log message for revision 101554:
  Removed import cycle for ``__show__``.
  
  Define the instance in the ``zope.deprecation.deprecation`` module, instead
  of in ``__init__.py``.
  

Changed:
  U   zope.deprecation/trunk/CHANGES.txt
  U   zope.deprecation/trunk/src/zope/deprecation/__init__.py
  U   zope.deprecation/trunk/src/zope/deprecation/deprecation.py

-=-
Modified: zope.deprecation/trunk/CHANGES.txt
===================================================================
--- zope.deprecation/trunk/CHANGES.txt	2009-07-04 16:42:04 UTC (rev 101553)
+++ zope.deprecation/trunk/CHANGES.txt	2009-07-04 16:44:55 UTC (rev 101554)
@@ -5,6 +5,9 @@
 3.4.1 (unreleased)
 ==================
 
+Removed import cycle for ``__show__`` by defining it in the
+``zope.deprecation.deprecation`` module.
+
 Added support to bootstrap on Jython.
 
 Fix zope.deprecation.warn() to make the signature identical to

Modified: zope.deprecation/trunk/src/zope/deprecation/__init__.py
===================================================================
--- zope.deprecation/trunk/src/zope/deprecation/__init__.py	2009-07-04 16:42:04 UTC (rev 101553)
+++ zope.deprecation/trunk/src/zope/deprecation/__init__.py	2009-07-04 16:44:55 UTC (rev 101554)
@@ -17,11 +17,8 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.deprecation.deprecation import deprecated, deprecate, ShowSwitch
+from zope.deprecation.deprecation import deprecated
+from zope.deprecation.deprecation import deprecate
 from zope.deprecation.deprecation import moved
-
-# This attribute can be used to temporarly deactivate deprecation
-# warnings, so that backward-compatibility code can import other
-# backward-compatiblity components without warnings being produced.
-
-__show__ = ShowSwitch()
+from zope.deprecation.deprecation import ShowSwitch
+from zope.deprecation.deprecation import __show__

Modified: zope.deprecation/trunk/src/zope/deprecation/deprecation.py
===================================================================
--- zope.deprecation/trunk/src/zope/deprecation/deprecation.py	2009-07-04 16:42:04 UTC (rev 101553)
+++ zope.deprecation/trunk/src/zope/deprecation/deprecation.py	2009-07-04 16:44:55 UTC (rev 101554)
@@ -23,9 +23,6 @@
 import types
 import warnings
 
-import zope.deprecation
-
-
 class ShowSwitch(object):
     """Simple stack-based switch."""
 
@@ -48,6 +45,11 @@
         return '<ShowSwitch %s>' %(self() and 'on' or 'off')
 
 
+# This attribute can be used to temporarly deactivate deprecation
+# warnings, so that backward-compatibility code can import other
+# backward-compatiblity components without warnings being produced.
+__show__ = ShowSwitch()
+
 ogetattr = object.__getattribute__
 class DeprecationProxy(object):
 
@@ -70,7 +72,7 @@
             return types.ModuleType
         
         if name in ogetattr(self, '_DeprecationProxy__deprecated'):
-            if zope.deprecation.__show__():
+            if __show__():
                 warnings.warn(
                     name + ': ' + self.__deprecated[name],
                     DeprecationWarning, 2)
@@ -103,7 +105,7 @@
         if name == '__class__':
             return types.ModuleType
         
-        if zope.deprecation.__show__():
+        if __show__():
             warnings.warn(self.__msg, DeprecationWarning, 2)
 
         return getattr(ogetattr(self, '_DeprecatedModule__original_module'),
@@ -126,28 +128,28 @@
         self.prop = prop
 
     def __get__(self, inst, klass):
-        if zope.deprecation.__show__():
+        if __show__():
             warnings.warn(self.message, DeprecationWarning, 2)
         return self.prop.__get__(inst, klass)
 
 class DeprecatedGetSetProperty(DeprecatedGetProperty):
 
     def __set__(self, inst, prop):
-        if zope.deprecation.__show__():
+        if __show__():
             warnings.warn(self.message, DeprecationWarning, 2)
         self.prop.__set__(inst, prop)
 
 class DeprecatedGetSetDeleteProperty(DeprecatedGetSetProperty):
 
     def __delete__(self, inst):
-        if zope.deprecation.__show__():
+        if __show__():
             warnings.warn(self.message, DeprecationWarning, 2)
         self.prop.__delete__(inst)
 
 def DeprecatedMethod(method, message):
 
     def deprecated_method(self, *args, **kw):
-        if zope.deprecation.__show__():
+        if __show__():
             warnings.warn(message, DeprecationWarning, 2)
         return method(self, *args, **kw)
 



More information about the Checkins mailing list