[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/deprecation/
Convenience deprecation decorator
Philipp von Weitershausen
philikon at philikon.de
Tue Feb 28 09:47:56 EST 2006
Log message for revision 65578:
Convenience deprecation decorator
Changed:
U Zope3/branches/jim-adapter/src/zope/deprecation/README.txt
U Zope3/branches/jim-adapter/src/zope/deprecation/deprecation.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/deprecation/README.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/deprecation/README.txt 2006-02-28 02:36:33 UTC (rev 65577)
+++ Zope3/branches/jim-adapter/src/zope/deprecation/README.txt 2006-02-28 14:47:54 UTC (rev 65578)
@@ -79,6 +79,10 @@
...
... def splat(self):
... return 4
+ ...
+ ... @deprecation.deprecate("clap() is no more.")
+ ... def clap(self):
+ ... return 5
And here is the result:
@@ -97,6 +101,11 @@
3
>>> my.splat()
4
+ >>> my.clap()
+ From tests.py's showwarning():
+ ...README.txt:1: DeprecationWarning: clap() is no more.
+ ...
+ 5
Temporarily Turning Off Deprecation Warnings
Modified: Zope3/branches/jim-adapter/src/zope/deprecation/deprecation.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/deprecation/deprecation.py 2006-02-28 02:36:33 UTC (rev 65577)
+++ Zope3/branches/jim-adapter/src/zope/deprecation/deprecation.py 2006-02-28 14:47:54 UTC (rev 65578)
@@ -152,3 +152,12 @@
return DeprecatedGetSetProperty(prop, message)
elif hasattr(prop, '__get__'):
return DeprecatedGetProperty(prop, message)
+
+class deprecate(object):
+ """Deprecation decorator"""
+
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __call__(self, func):
+ return DeprecatedMethod(func, self.msg)
More information about the Zope3-Checkins
mailing list