[Zope-dev] Re: zLOG deprecation?
Philipp von Weitershausen
philipp at weitershausen.de
Wed Dec 7 03:18:02 EST 2005
Chris Withers wrote:
> Philipp von Weitershausen wrote:
> > This would probably best be handled by one person, so if you are willing to do all
> > the grepping and updating, making zLOG deprecated would just be a minor operation :).
>
> ...but one i don't know how to perform. What code would I insert and where?
See below :). Of course, you don't have to deprecate zLOG instantly. Removing all of its
references could already be done now.
> I'm happy to sign up for this, but can't promise when it'll happen...
So let's schedule it for Zope 2.10 then :).
> > In zLOG.LOG one would call warnings.warn()
>
> Ah, okay :-)
A typical call to warnings.warn() looks like this::
warnings.warn("This is deprecated, dude", DeprecationWarning, stacklevel=2)
The stacklevel=2 is important because the deprecation warning "traceback" wouldn't point
to the offending code otherwise.
> > and the custom zLOG logging level constants could
> > be wrapped in a deprecation warnings (zope.deprecation.deprecate)
>
> How would I do this? Can you give me an example?
Use the doctests, Luke :). Anyway, here's an example:
http://svn.zope.org/Zope3/trunk/src/zope/i18nmessageid/__init__.py?rev=39525&view=auto
It shows how to wrap stuff in deprecation proxies using zope.deprecation.deprecate(). Then
any access to these objects (e.g. importing) will trigger a warning. It also demonstrates
how to temporarily turn off those deprecation warnings, for example when you're using
deprecated stuff for internal use, such as still supporting old import locations (as in
this case).
Philipp
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the Zope-Dev
mailing list