Back to index

plone3  3.1.7
deprecated.py
Go to the documentation of this file.
00001 # -*- coding: ISO-8859-15 -*-
00002 # Copyright (c) 2005-2007
00003 # Authors: KSS Project Contributors (see docs/CREDITS.txt)
00004 #
00005 # This program is free software; you can redistribute it and/or modify
00006 # it under the terms of the GNU General Public License version 2 as published
00007 # by the Free Software Foundation.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 # GNU General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU General Public License
00015 # along with this program; if not, write to the Free Software
00016 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017 # 02111-1307, USA.
00018 
00019 import warnings, textwrap
00020 
00021 def deprecated_warning(message):
00022     warnings.warn(message, DeprecationWarning, 2)
00023 
00024 def deprecated(method, message):
00025     def deprecated_method(self, *args, **kw):
00026         warnings.warn(message, DeprecationWarning, 2)
00027         return method(self, *args, **kw)
00028     return deprecated_method
00029 
00030 def deprecated_directive(method, directive, message):
00031     def deprecated_method(_context, *args, **kw):
00032         warnings.warn(message, DeprecationWarning, 2)
00033         warnings.warn(textwrap.dedent('''\
00034 
00035 
00036               %s
00037             The directive %s is deprecated and will be removed any time,
00038             %s
00039             '''
00040             % (_context.info, directive, message)),
00041         DeprecationWarning, 2)
00042         return method(_context, *args, **kw)
00043     return deprecated_method