r366 - / python-zope.deprecation python-zope.deprecation/branches python-zope.deprecation/branches/upstream python-zope.deprecation/branches/upstream/current python-zope.deprecation/branches/upstream/current/src python-zope.deprecation/branches/upstream/current/src/zope python-zope.deprecation/branches/upstream/current/src/zope/deprecation python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info python-zope.deprecation/branches/upstream/current/workspace

Brian Sutherland jinty-guest at alioth.debian.org
Sun Oct 29 20:19:45 CET 2006


Author: jinty-guest
Date: 2006-10-29 20:19:36 +0100 (Sun, 29 Oct 2006)
New Revision: 366

Added:
   python-zope.deprecation/
   python-zope.deprecation/branches/
   python-zope.deprecation/branches/upstream/
   python-zope.deprecation/branches/upstream/current/
   python-zope.deprecation/branches/upstream/current/CHANGES.txt
   python-zope.deprecation/branches/upstream/current/INSTALL.txt
   python-zope.deprecation/branches/upstream/current/MANIFEST.in
   python-zope.deprecation/branches/upstream/current/PKG-INFO
   python-zope.deprecation/branches/upstream/current/README.txt
   python-zope.deprecation/branches/upstream/current/develop.py
   python-zope.deprecation/branches/upstream/current/setup.cfg.in
   python-zope.deprecation/branches/upstream/current/setup.py
   python-zope.deprecation/branches/upstream/current/src/
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/PKG-INFO
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/SOURCES.txt
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/namespace_packages.txt
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/not-zip-safe
   python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/top_level.txt
   python-zope.deprecation/branches/upstream/current/src/zope/
   python-zope.deprecation/branches/upstream/current/src/zope/__init__.py
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/DEPENDENCIES.cfg
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/README.txt
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/__init__.py
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/deprecation.py
   python-zope.deprecation/branches/upstream/current/src/zope/deprecation/tests.py
   python-zope.deprecation/branches/upstream/current/test.py
   python-zope.deprecation/branches/upstream/current/workspace/
   python-zope.deprecation/branches/upstream/current/workspace/__init__.py
   python-zope.deprecation/branches/upstream/current/workspace/develop.py
   python-zope.deprecation/tags/
Log:
[svn-inject] Installing original source of python-zope.deprecation

Added: python-zope.deprecation/branches/upstream/current/CHANGES.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/CHANGES.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/CHANGES.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,22 @@
+zope.deprecation Package Changelog
+==================================
+
+zope.deprecation version 3.2.0.1 (2006/04/14)
+---------------------------------------------
+
+- Packaging change:  suppress inclusion of 'setup.cfg' in 'sdist' builds.
+
+zope.deprecation version 3.2.0 (2006/01/05)
+-------------------------------------------
+
+- Corresponds to the verison of the zope.deprecation package shipped as part of
+  the Zope 3.2.0 release.
+
+- Refactored to eliminate dependency on 'zope.proxy'. This was an especially
+  bad dependency due to the required C exension in 'zope.proxy'.
+
+zope.deprecation version 3.1.0 (2005/10/03)
+-------------------------------------------
+
+- Corresponds to the verison of the zope.deprecation package shipped as part of
+  the Zope 3.1.0 release.


Property changes on: python-zope.deprecation/branches/upstream/current/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/INSTALL.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/INSTALL.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/INSTALL.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,83 @@
+Installing This Package
+=======================
+
+Prerequisites
+-------------
+
+The installation steps below assume that you have the cool new 'setuptools'
+package installed in your Python.  Here is where to get it:
+
+  $ wget http://peak.telecommunity.com/dist/ez_setup.py
+  $ /path/to/your/python ez_setup.py # req. write access to 'site-packages'
+
+
+  - Docs for EasyInstall:
+    http://peak.telecommunity.com/DevCenter/EasyInstall
+
+  - Docs for setuptools:
+    http://peak.telecommunity.com/DevCenter/setuptools
+
+  - Docs for eggs:
+    http://peak.telecommunity.com/DevCenter/PythonEggs
+
+
+Installing a Development Checkout
+---------------------------------
+
+Check out the package from subversion:
+
+  $ svn co svn+ssh://svn.zope.org/repos/main/zope.deprecation/trunk \
+    src/zope.deprecation
+  $ cd src/zope.deprecation
+
+Install it as a "devlopment egg" (which also installs its "hard"
+dependencies):
+
+  $ /path/to/your/python setup.py devel
+
+The installation of dependency eggs uses the 'setup.cfg' file in
+the checkout.  You can supply '--find-links' on the command line to
+point it at a non-standard package repository.
+
+
+Running the Tests
+-----------------
+
+To test the package, you will also need the 'zope.testing' package, which
+can't (yet) be automatically installed.  Eventually, you should be able to
+type:
+
+  $ /path/to/your/python setup.py test
+
+and have it install the "testing dependencies."  Today, the workaround
+is to install it manually:
+
+  $ /path/to/easy_install --find-links="...." zope.testing
+
+You can then run the tests (finally) from the checkout directory:
+
+  $ /path/to/your/python test.py
+    Running:
+      .............
+    Ran 13 tests with 0 failures and 0 errors in 0.094 seconds.
+
+
+Installing a Source Distribution
+--------------------------------
+
+You can also install it from a source distribution:
+
+  $ /path/to/easy_install --find-links="...." -eb src zope.deprecation
+  $ cd src/zope.deprecation
+  $ /path/to/your/python setup.py devel
+
+
+Installing a Binary Egg
+-----------------------
+
+Install the package as a "binary egg" (which also installs its "hard"
+dependencies):
+
+  $ /path/to/easy_install --find-links="...." zope.deprecation
+
+


Property changes on: python-zope.deprecation/branches/upstream/current/INSTALL.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/MANIFEST.in
===================================================================
--- python-zope.deprecation/branches/upstream/current/MANIFEST.in	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/MANIFEST.in	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1 @@
+exclude setup.cfg

Added: python-zope.deprecation/branches/upstream/current/PKG-INFO
===================================================================
--- python-zope.deprecation/branches/upstream/current/PKG-INFO	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/PKG-INFO	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: zope.deprecation
+Version: 3.2.0.2
+Summary: Zope 3 Deprecation Infrastructure
+Home-page: http://svn.zope.org/zope.deprecation/tags/3.2.0
+Author: Zope Corporation and Contributors
+Author-email: zope3-dev at zope.org
+License: ZPL 2.1
+Description: This package provides a simple function called 'deprecated(names, reason)', which Zope3 uses to mark APIs and components which will be removed in future releases.
+Platform: UNKNOWN

Added: python-zope.deprecation/branches/upstream/current/README.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/README.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/README.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,41 @@
+zope.deprecation Package Readme
+===============================
+
+Overview
+--------
+
+When we started working on Zope 3.1, we noticed that the hardest part of the
+development process was to ensure backward-compatibility and correctly mark
+deprecated modules, classes, functions, methods and properties. This package
+provides a simple function called 'deprecated(names, reason)' to deprecate the
+previously mentioned Python objects.
+
+Changes
+-------
+
+See CHANGES.txt.
+
+Installation
+------------
+
+See INSTALL.txt.
+
+
+Developer Resources
+-------------------
+
+- Subversion browser:
+
+  http://svn.zope.org/zope.deprecation/
+
+- Read-only Subversion checkout:
+
+  $ svn co svn://svn.zope.org/repos/main/zope.deprecation/trunk
+
+- Writable Subversion checkout:
+
+  $ svn co svn://svn.zope.org/repos/main/zope.deprecation/trunk
+
+- Note that the 'src/zope/deprecation' package is acutally a 'svn:externals'
+  link to the corresponding package in the Zope3 trunk (or to a specific tag,
+  for released versions of the package).


Property changes on: python-zope.deprecation/branches/upstream/current/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/develop.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/develop.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/develop.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,21 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Workspace configuration wrapper script
+
+$Id$
+"""
+
+import workspace.develop
+
+workspace.develop.main()


Property changes on: python-zope.deprecation/branches/upstream/current/develop.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/setup.cfg.in
===================================================================
--- python-zope.deprecation/branches/upstream/current/setup.cfg.in	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/setup.cfg.in	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,2 @@
+[development]
+depends = zope.testing

Added: python-zope.deprecation/branches/upstream/current/setup.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/setup.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/setup.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,47 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Setup for zope.deprecation package
+
+$Id$
+"""
+
+import os
+
+try:
+    from setuptools import setup, Extension, find_packages
+    
+except ImportError, e:
+    from distutils.core import setup, Extension
+    
+setup(name='zope.deprecation',
+      version='3.2.0.2',
+
+      url='http://svn.zope.org/zope.deprecation/tags/3.2.0',
+      license='ZPL 2.1',
+      description='Zope 3 Deprecation Infrastructure',
+      author='Zope Corporation and Contributors',
+      author_email='zope3-dev at zope.org',
+      long_description="This package provides a simple function called "
+                       "'deprecated(names, reason)', which Zope3 uses to "
+                       "mark APIs and components which will be removed in "
+                       "future releases.",
+      
+      package_dir = {'': 'src'},
+      packages=['zope', 'zope.deprecation'],
+      namespace_packages=['zope',],
+
+      tests_require = ['zope.testing'],
+      include_package_data = True,
+      zip_safe = False,
+      )


Property changes on: python-zope.deprecation/branches/upstream/current/setup.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope/__init__.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/__init__.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/__init__.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,6 @@
+# namespace package boilerplate
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/DEPENDENCIES.cfg
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/deprecation/DEPENDENCIES.cfg	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/deprecation/DEPENDENCIES.cfg	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1 @@
+zope.testing

Added: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/README.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/deprecation/README.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/deprecation/README.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,173 @@
+===============
+Deprecation API
+===============
+
+When we started working on Zope 3.1, we noticed that the hardest part of the
+development process was to ensure backward-compatibility and correctly mark
+deprecated modules, classes, functions, methods and properties. This module
+provides a simple function called `deprecated(names, reason)` to deprecate the
+previously mentioned Python objects.
+
+Let's start with a demonstration of deprecating any name inside a module. To
+demonstrate the functionality, I have placed the following code inside the
+`tests.py` file of this package:
+
+  from zope.deprecation import deprecated
+  demo1 = 1
+  deprecated('demo1', 'demo1 is no more.')
+
+  demo2 = 2
+  deprecated('demo2', 'demo2 is no more.')
+
+  demo3 = 3
+  deprecated('demo3', 'demo3 is no more.')
+
+The first argument to the `deprecated()` function is a list of names that
+should be declared deprecated. If the first argument is a string, it is
+interpreted as one name. The second argument is the reason the particular name
+has been deprecated. It is good practice to also list the version in which the
+name will be removed completely.
+
+Let's now see how the deprecation warnings are displayed.
+
+  >>> from zope.deprecation import tests
+  >>> tests.demo1
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo1: demo1 is no more.
+  ...
+  1
+
+  >>> import zope.deprecation.tests
+  >>> zope.deprecation.tests.demo2
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo2: demo2 is no more.
+  ...
+  2
+
+You can see that merely importing the affected module or one of its parents
+does not cause a deprecation warning. Only when we try to access the name in
+the module, we get a deprecation warning. On the other hand, if we import the
+name directly, the deprecation warning will be raised immediately.
+
+  >>> from zope.deprecation.tests import demo3
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: demo3: demo3 is no more.
+  ...
+
+Also, once a deprecation warning has been displayed, it is not shown again:
+
+  >>> from zope.deprecation import tests
+  >>> tests.demo1
+  1
+
+New let's see how properties and methods can be deprecated. We are going to
+use the same function as before, except that this time, we do not pass in names
+as first argument, but the method or attribute itself. The function then
+returns a wrapper that sends out a deprecation warning when the attribute or
+method is accessed.
+
+  >>> from zope.deprecation import deprecation
+  >>> class MyComponent(object):
+  ...     foo = property(lambda self: 1)
+  ...     foo = deprecation.deprecated(foo, 'foo is no more.')
+  ...
+  ...     bar = 2
+  ...
+  ...     def blah(self):
+  ...         return 3
+  ...     blah = deprecation.deprecated(blah, 'blah() is no more.')
+  ...
+  ...     def splat(self):
+  ...         return 4
+
+And here is the result:
+
+  >>> my = MyComponent()
+  >>> my.foo
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: foo is no more.
+  ...
+  1
+  >>> my.bar
+  2
+  >>> my.blah()
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: blah() is no more.
+  ...
+  3
+  >>> my.splat()
+  4
+
+
+Temporarily Turning Off Deprecation Warnings
+--------------------------------------------
+
+In some cases it is desireable to turn off the deprecation warnings for a
+short time. To support such a feature, the `zope.deprecation` package provides
+an attribute called `__show__`. One can ask for its status by calling it:
+
+  >>> from zope.deprecation import __show__
+  >>> __show__()
+  True
+
+  >>> class Foo(object):
+  ...     bar = property(lambda self: 1)
+  ...     bar = deprecation.deprecated(bar, 'bar is no more.')
+  ...     blah = property(lambda self: 1)
+  ...     blah = deprecation.deprecated(blah, 'blah is no more.')
+  >>> foo = Foo()
+
+  >>> foo.bar
+  From tests.py's showwarning():
+  ...README.txt:1: DeprecationWarning: bar is no more.
+  ...
+  1
+
+You can turn off the depraction warnings using
+
+  >>> __show__.off()
+  >>> __show__()
+  False
+
+  >>> foo.blah
+  1
+
+Now, you can also nest several turn-offs, so that calling `off()` multiple
+times is meaningful:
+
+  >>> __show__.stack
+  [False]
+
+  >>> __show__.off()
+  >>> __show__.stack
+  [False, False]
+
+  >>> __show__.on()
+  >>> __show__.stack
+  [False]
+  >>> __show__()
+  False
+
+  >>> __show__.on()
+  >>> __show__.stack
+  []
+  >>> __show__()
+  True
+
+You can also reset `__show__` to `True`:
+
+  >>> __show__.off()
+  >>> __show__.off()
+  >>> __show__()
+  False
+
+  >>> __show__.reset()
+  >>> __show__()
+  True
+
+Finally, you cannot call `on()` without having called `off()` before:
+
+  >>> __show__.on()
+  Traceback (most recent call last):
+  ...
+  IndexError: pop from empty list


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/README.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/__init__.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/deprecation/__init__.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/deprecation/__init__.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Deprecation Package
+
+$Id: __init__.py 37507 2005-07-27 22:48:36Z anguenot $
+"""
+__docformat__ = "reStructuredText"
+
+from zope.deprecation.deprecation import deprecated, ShowSwitch
+
+# 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()


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/deprecation.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/deprecation/deprecation.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/deprecation/deprecation.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,154 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Deprecation Support
+
+This module provides utilities to ease the development of backward-compatible
+code.
+
+$Id: deprecation.py 40198 2005-11-17 20:49:20Z jim $
+"""
+__docformat__ = "reStructuredText"
+import sys
+import types
+import warnings
+
+import zope.deprecation
+
+
+class ShowSwitch(object):
+    """Simple stack-based switch."""
+
+    def __init__(self):
+        self.stack = []
+
+    def on(self):
+        self.stack.pop()
+
+    def off(self):
+        self.stack.append(False)
+
+    def reset(self):
+        self.stack = []
+
+    def __call__(self):
+        return self.stack == []
+
+    def __repr__(self):
+        return '<ShowSwitch %s>' %(self() and 'on' or 'off')
+
+
+ogetattr = object.__getattribute__
+class DeprecationProxy(object):
+
+    def __init__(self, module):
+        self.__original_module = module
+        self.__deprecated = {}
+
+    def deprecate(self, names, message):
+        """Deprecate the given names."""
+        if not isinstance(names, (tuple, list)):
+            names = (names,)
+        for name in names:
+            self.__deprecated[name] = message
+
+    def __getattribute__(self, name):
+        if name == 'deprecate' or name.startswith('_DeprecationProxy__'):
+            return ogetattr(self, name)
+
+        if name == '__class__':
+            return types.ModuleType
+        
+        if name in ogetattr(self, '_DeprecationProxy__deprecated'):
+            if zope.deprecation.__show__():
+                warnings.warn(
+                    name + ': ' + self.__deprecated[name],
+                    DeprecationWarning, 2)
+
+        return getattr(ogetattr(self, '_DeprecationProxy__original_module'),
+                       name)
+
+    def __setattr__(self, name, value):
+        if name.startswith('_DeprecationProxy__'):
+            return object.__setattr__(self, name, value)
+
+        setattr(self.__original_module, name, value)
+
+    def __delattr__(self, name):
+        if name.startswith('_DeprecationProxy__'):
+            return object.__delattr__(self, name)
+
+        delattr(self.__original_module, name)
+        
+
+class DeprecatedGetProperty(object):
+
+    def __init__(self, prop, message):
+        self.message = message
+        self.prop = prop
+
+    def __get__(self, inst, klass):
+        if zope.deprecation.__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__():
+            warnings.warn(self.message, DeprecationWarning, 2)
+        self.prop.__set__(inst, prop)
+
+class DeprecatedGetSetDeleteProperty(DeprecatedGetSetProperty):
+
+    def __delete__(self, inst):
+        if zope.deprecation.__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__():
+            warnings.warn(message, DeprecationWarning, 2)
+        return method(self, *args, **kw)
+
+    return deprecated_method
+
+
+def deprecated(specifier, message):
+    """Deprecate the given names."""
+
+    # We are inside a module
+    if isinstance(specifier, (str, unicode, list, tuple)):
+        locals = sys._getframe(1).f_locals
+        if '__name__' in locals:
+            modname = locals['__name__']
+
+        if not isinstance(sys.modules[modname], DeprecationProxy):
+            sys.modules[modname] = DeprecationProxy(sys.modules[modname])
+        sys.modules[modname].deprecate(specifier, message)
+
+
+    # ... that means the specifier is a method or attribute of the class
+    if isinstance(specifier, types.FunctionType):
+        return DeprecatedMethod(specifier, message)
+    else:
+        prop = specifier
+        if hasattr(prop, '__get__') and hasattr(prop, '__set__') and \
+               hasattr(prop, '__delete__'):
+            return DeprecatedGetSetDeleteProperty(prop, message)
+        elif hasattr(prop, '__get__') and hasattr(prop, '__set__'):
+            return DeprecatedGetSetProperty(prop, message)
+        elif hasattr(prop, '__get__'):
+            return DeprecatedGetProperty(prop, message)


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/deprecation.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/tests.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope/deprecation/tests.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope/deprecation/tests.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Component Architecture Tests
+
+$Id: tests.py 30324 2005-05-11 09:45:33Z hdima $
+"""
+import sys
+import unittest
+import warnings
+from zope.testing import doctest
+
+# Used in doctests
+from deprecation import deprecated
+demo1 = 1
+deprecated('demo1', 'demo1 is no more.')
+
+demo2 = 2
+deprecated('demo2', 'demo2 is no more.')
+
+demo3 = 3
+deprecated('demo3', 'demo3 is no more.')
+
+
+orig_showwarning = warnings.showwarning
+
+def showwarning(message, category, filename, lineno, file=None):
+    sys.stdout.write("From tests.py's showwarning():\n")
+    sys.stdout.write(
+        warnings.formatwarning(message, category, filename, lineno))
+
+def setUp(test):
+    warnings.showwarning = showwarning
+
+def tearDown(test):
+    warnings.showwarning = orig_showwarning
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocFileSuite('README.txt',
+                             setUp=setUp, tearDown=tearDown,
+                             optionflags=doctest.ELLIPSIS),
+        ))
+
+if __name__ == "__main__":
+    unittest.main(defaultTest='test_suite')


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope/deprecation/tests.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/PKG-INFO
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/PKG-INFO	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/PKG-INFO	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: zope.deprecation
+Version: 3.2.0.2
+Summary: Zope 3 Deprecation Infrastructure
+Home-page: http://svn.zope.org/zope.deprecation/tags/3.2.0
+Author: Zope Corporation and Contributors
+Author-email: zope3-dev at zope.org
+License: ZPL 2.1
+Description: This package provides a simple function called 'deprecated(names, reason)', which Zope3 uses to mark APIs and components which will be removed in future releases.
+Platform: UNKNOWN

Added: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/SOURCES.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/SOURCES.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/SOURCES.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,21 @@
+CHANGES.txt
+INSTALL.txt
+MANIFEST.in
+README.txt
+develop.py
+setup.cfg.in
+setup.py
+test.py
+src/zope/__init__.py
+src/zope.deprecation.egg-info/PKG-INFO
+src/zope.deprecation.egg-info/SOURCES.txt
+src/zope.deprecation.egg-info/namespace_packages.txt
+src/zope.deprecation.egg-info/not-zip-safe
+src/zope.deprecation.egg-info/top_level.txt
+src/zope/deprecation/DEPENDENCIES.cfg
+src/zope/deprecation/README.txt
+src/zope/deprecation/__init__.py
+src/zope/deprecation/deprecation.py
+src/zope/deprecation/tests.py
+workspace/__init__.py
+workspace/develop.py


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/SOURCES.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/namespace_packages.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/namespace_packages.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/namespace_packages.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1 @@
+zope


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/namespace_packages.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/not-zip-safe
===================================================================

Added: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/top_level.txt
===================================================================
--- python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/top_level.txt	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/top_level.txt	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1 @@
+zope


Property changes on: python-zope.deprecation/branches/upstream/current/src/zope.deprecation.egg-info/top_level.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/test.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/test.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/test.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Sample test script using zope.testing.testrunner
+
+see zope.testing testrunner.txt
+
+$Id$
+"""
+
+import os, sys
+
+src = os.path.join(os.path.split(sys.argv[0])[0], 'src')
+
+sys.path.insert(0, src) # put at beginning to avoid one in site_packages
+
+from zope.testing import testrunner
+
+defaults = [
+    '--path', src,
+    '--package', 'zope.deprecation',
+    '--tests-pattern', '^tests$',
+    ]
+
+sys.exit(testrunner.run(defaults))
+


Property changes on: python-zope.deprecation/branches/upstream/current/test.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/workspace/__init__.py
===================================================================


Property changes on: python-zope.deprecation/branches/upstream/current/workspace/__init__.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: python-zope.deprecation/branches/upstream/current/workspace/develop.py
===================================================================
--- python-zope.deprecation/branches/upstream/current/workspace/develop.py	2006-10-26 13:28:54 UTC (rev 365)
+++ python-zope.deprecation/branches/upstream/current/workspace/develop.py	2006-10-29 19:19:36 UTC (rev 366)
@@ -0,0 +1,177 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Project checkout setup script
+
+$Id$
+"""
+
+import os
+import sys
+import shutil
+import optparse
+import ConfigParser
+import urllib2
+
+DEV_SECTION = 'development'
+DEV_DEPENDS = 'depends'
+
+def bootstrap(libdir, bindir):
+    """Bootstrap our setuptools installation in the target directory."""
+
+    # make sure ez_setup is available
+    try:
+        # check if we have ez_setup available
+        import ez_setup
+        
+    except ImportError, e:
+        # retrieve ez_setup.py from the interweb
+        EZ_URL = "http://peak.telecommunity.com/dist/ez_setup.py"
+        
+        ez_filename = os.path.join(os.path.dirname(__file__), 'ez_setup.py')
+        file(ez_filename, 'w').write(
+            urllib2.urlopen(EZ_URL).read()
+            )
+
+        import ez_setup
+        
+    os.environ['PYTHONPATH'] = (os.environ.setdefault('PYTHONPATH', '')
+                               + ":" + libdir)
+    ez_setup.main(['--install-dir', libdir,
+                   '--script-dir', bindir,
+                   '-U', 'setuptools'])
+
+def initSetupCfg(setup_file, template_file='setup.cfg.in'):
+    """Check if the setup_file (setup.cfg) exists; if it doesn't, and
+    setup.cfg.in does, copy setup.cfg.in to setup.cfg to serve as a
+    template."""
+
+    if not(os.path.exists(setup_file)) and os.path.exists(template_file):
+        shutil.copyfile(template_file, setup_file)
+        
+def updateSetupCfg(setup_file, opts):
+    """Update or create a setup.cfg (setup_file) for working on this
+    project."""
+
+    # initialize the setup file if necessary
+    initSetupCfg(setup_file)
+    
+    # load the existing version
+    setup_cfg = ConfigParser.ConfigParser()
+    setup_cfg.read(setup_file)
+
+    # make sure the sections we want exist
+    if not(setup_cfg.has_section('easy_install')):
+        setup_cfg.add_section('easy_install')
+
+    if not(setup_cfg.has_section('egg_info')):
+        setup_cfg.add_section('egg_info')
+        
+    # update lib dir
+    if opts.libdir is None:
+        # no libdir specified; check for one in setup.cfg
+        if setup_cfg.has_option('easy_install', 'install-dir'):
+            opts.libdir = setup_cfg.get('easy_install', 'install-dir')
+        else:
+            opts.libdir = os.path.abspath('./lib')
+
+    setup_cfg.set('easy_install', 'install-dir', opts.libdir)
+
+    # update bin dir
+    if opts.bindir is None:
+        # no bindir specified; check for one in setup.cfg
+        if setup_cfg.has_option('easy_install', 'script-dir'):
+            opts.bindir = setup_cfg.get('easy_install', 'script-dir')
+        else:
+            opts.bindir = os.path.abspath('./bin')
+
+    setup_cfg.set('easy_install', 'script-dir', opts.bindir)
+        
+    # update site-dirs
+    setup_cfg.set('easy_install', 'site-dirs', opts.libdir)
+    
+    # update find-links
+    setup_cfg.set('easy_install', 'find-links', opts.finddirs)
+
+    # update egg_info for development version
+    if not setup_cfg.has_option('egg_info', 'tag_build'):
+        setup_cfg.set('egg_info', 'tag_build', '.dev')
+
+    if not setup_cfg.has_option('egg_info', 'tag_svn_revision'):
+        setup_cfg.set('egg_info', 'tag_svn_revision', '1')
+
+    # store the updated version
+    setup_cfg.write(file(setup_file, 'w'))
+
+def load_dev_deps(setup_file):
+    global DEV_SECTION
+    global DEV_DEPENDS
+    
+    # load the existing version
+    setup_cfg = ConfigParser.ConfigParser()
+    setup_cfg.read(setup_file)
+
+    if not(setup_cfg.has_option(DEV_SECTION, DEV_DEPENDS)):
+        return []
+    else:
+        return [n.strip() for n in
+                setup_cfg.get(DEV_SECTION, DEV_DEPENDS).strip().split()]
+
+def check_dirs(*dirs):
+    """Check that our target directories all exist."""
+
+    for d in dirs:
+        if not(os.path.exists(os.path.abspath(d))):
+            os.makedirs(os.path.abspath(d))
+
+def cmdline_parser():
+    """Create an option parser and populate our available options."""
+
+    parser = optparse.OptionParser()
+    parser.add_option("-s", "--file", dest="setup_cfg",
+                      help="File to read setup configuration from." )
+    parser.add_option("-l", "--libdir", dest="libdir",
+                      help="Location of Python libraries.")
+    parser.add_option("-b", "--bindir", dest="bindir",
+                      help="Location of Python scripts.")
+    parser.add_option("-f", "--find-dirs", dest="finddirs",
+                      help="Location to examine for package links.")
+
+    parser.set_defaults(setup_cfg="setup.cfg",
+                        libdir=None,
+                        bindir=None,
+                        finddirs="http://download.zope.org/distribution/")
+
+    return parser
+
+def main():
+    (options, args) = cmdline_parser().parse_args()
+
+    # update setup.cfg with the lib dir, bin dir, etc
+    updateSetupCfg(options.setup_cfg, options)
+    
+    # make sure that the lib directory structure of our prefix exists
+    check_dirs(options.bindir, options.libdir)
+    sys.path.insert(0, options.libdir)
+
+    # bootstrap setuptools into our libdir
+    bootstrap(options.libdir, options.bindir)
+
+    # install the development dependencies
+    from setuptools.command.easy_install import main as einstall
+    deps = load_dev_deps(options.setup_cfg)
+    if deps and len(deps) > 0:
+        einstall(deps)
+    
+if __name__ == '__main__':
+    main()


Property changes on: python-zope.deprecation/branches/upstream/current/workspace/develop.py
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the pkg-zope-commits mailing list