[Checkins] SVN: zope.proxy/trunk/ - Bug: Updated `setup.py` script
to conform to common layout. Also updated
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Jun 24 08:23:51 EDT 2008
Log message for revision 87706:
- Bug: Updated `setup.py` script to conform to common layout. Also updated
some of the fields.
- Bug: The behavior of tuples and lists in the `__getslice__()` and
`__setslice__()` method were incorrect by not honoring the pre-cooked
indices. See http://docs.python.org/ref/sequence-methods.html.
Changed:
A zope.proxy/trunk/CHANGES.txt
U zope.proxy/trunk/README.txt
U zope.proxy/trunk/buildout.cfg
U zope.proxy/trunk/setup.py
U zope.proxy/trunk/src/zope/proxy/_zope_proxy_proxy.c
U zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py
-=-
Added: zope.proxy/trunk/CHANGES.txt
===================================================================
--- zope.proxy/trunk/CHANGES.txt (rev 0)
+++ zope.proxy/trunk/CHANGES.txt 2008-06-24 12:23:50 UTC (rev 87706)
@@ -0,0 +1,39 @@
+=======
+CHANGES
+=======
+
+3.4.1 (2008/06/24)
+------------------
+
+- Bug: Updated `setup.py` script to conform to common layout. Also updated
+ some of the fields.
+
+- Bug: The behavior of tuples and lists in the `__getslice__()` and
+ `__setslice__()` method were incorrect by not honoring the pre-cooked
+ indices. See http://docs.python.org/ref/sequence-methods.html.
+
+3.4.0 (2007/07/12)
+------------------
+
+- Feature: Added a decorator module that supports declaring interfaces on
+ proxies that get blended with the interfaces of the things they proxy.
+
+3.3.0 (2006/12/20)
+------------------
+
+- Corresponds to the verison of the `zope.proxy` package shipped as part of
+ the Zope 3.3.0 release.
+
+
+3.2.0 (2006/01/05)
+------------------
+
+- Corresponds to the verison of the zope.proxy package shipped as part of
+ the Zope 3.2.0 release.
+
+
+3.0.0 (2004/11/07)
+------------------
+
+- Corresponds to the verison of the zope.proxy package shipped as part of
+ the Zope X3.0.0 release.
Property changes on: zope.proxy/trunk/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: zope.proxy/trunk/README.txt
===================================================================
--- zope.proxy/trunk/README.txt 2008-06-24 12:18:51 UTC (rev 87705)
+++ zope.proxy/trunk/README.txt 2008-06-24 12:23:50 UTC (rev 87706)
@@ -1,6 +1,7 @@
-***************************
+
+===========================
Generic Transparent Proxies
-***************************
+===========================
Proxies are special objects which serve as mostly-transparent
wrappers around another object, intervening in the apparent behavior of
@@ -9,39 +10,7 @@
Editorial note:
- Unfortunately, we don't have separate documentation for zope.proxy
- at this time. This is a shame because the are generically useful.
+ Unfortunately, we don't have separate documentation for `zope.proxy`
+ at this time. This is a shame because they are generically useful.
We are publishing this release without documentation mainly because
it is a dependency of other releases.
-
-Changes
-*******
-
-3.4.0 (2007/07/12)
-==================
-
-New Features
-------------
-
-Added a decorator module that supports declaring interfaces on proxies
-that get blended with the interfaces of the things they proxy.
-
-3.3.0 (2006/12/20)
-==================
-
-Corresponds to the verison of the zope.proxy package shipped as part of
-the Zope 3.3.0 release.
-
-
-3.2.0 (2006/01/05)
-==================
-
-Corresponds to the verison of the zope.proxy package shipped as part of
-the Zope 3.2.0 release.
-
-
-3.0.0 (2004/11/07)
-==================
-
-Corresponds to the verison of the zope.proxy package shipped as part of
-the Zope X3.0.0 release.
Modified: zope.proxy/trunk/buildout.cfg
===================================================================
--- zope.proxy/trunk/buildout.cfg 2008-06-24 12:18:51 UTC (rev 87705)
+++ zope.proxy/trunk/buildout.cfg 2008-06-24 12:23:50 UTC (rev 87706)
@@ -4,4 +4,4 @@
[test]
recipe = zc.recipe.testrunner
-eggs = zope.proxy
+eggs = zope.proxy [test]
Modified: zope.proxy/trunk/setup.py
===================================================================
--- zope.proxy/trunk/setup.py 2008-06-24 12:18:51 UTC (rev 87705)
+++ zope.proxy/trunk/setup.py 2008-06-24 12:23:50 UTC (rev 87706)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -15,39 +15,38 @@
$Id$
"""
-
import os
-
from setuptools import setup, Extension
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-long_description=(
- read('README.txt')
- + '\n' +
-# Waaa 'Detailed Documentation\n'
-# '**********************\n'
-# + '\n' +
-# + '\n' +
- 'Download\n'
- '**********************\n'
- )
-
-open('doc.txt', 'w').write(long_description)
-
-name = 'zope.proxy'
-setup(name=name,
- version = '3.4.0',
- url='http://www.python.org/pypi/'+name,
+setup(name='zope.proxy',
+ version = '3.4.1',
+ author='Zope Corporation and Contributors',
+ author_email='zope-dev at zope.org',
+ description='Generic Transparent Proxies',
+ long_description=(
+ read('README.txt')
+ + '\n\n' +
+# Waaa 'Detailed Documentation\n'
+# '----------------------\n'
+# + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ url='http://pypi.python.org/pypi/zope.proxy',
license='ZPL 2.1',
- description='Generic Transparent Proxies',
- author='Zope Corporation and Contributors',
- author_email='zope3-dev at zope.org',
- long_description=long_description,
-
+ classifiers = [
+ 'Development Status :: 5 - Production/Stable',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent'],
+ keywords='proxy generic transparent',
packages=['zope', 'zope.proxy'],
package_dir = {'': 'src'},
+ namespace_packages=['zope',],
headers=[os.path.join('src', 'zope', 'proxy', 'proxy.h')],
ext_modules=[Extension("zope.proxy._zope_proxy_proxy",
@@ -56,9 +55,13 @@
]),
],
- namespace_packages=['zope',],
- tests_require = ['zope.testing'],
- install_requires=['zope.interface', 'setuptools'],
+ extras_require=dict(
+ test=['zope.testing']),
+ tests_require = [
+ 'zope.testing'],
+ install_requires=[
+ 'zope.interface',
+ 'setuptools'],
include_package_data = True,
zip_safe = False,
)
Modified: zope.proxy/trunk/src/zope/proxy/_zope_proxy_proxy.c
===================================================================
--- zope.proxy/trunk/src/zope/proxy/_zope_proxy_proxy.c 2008-06-24 12:18:51 UTC (rev 87705)
+++ zope.proxy/trunk/src/zope/proxy/_zope_proxy_proxy.c 2008-06-24 12:23:50 UTC (rev 87706)
@@ -629,13 +629,28 @@
static PyObject *
wrap_slice(PyObject *self, int start, int end)
{
- return PySequence_GetSlice(Proxy_GET_OBJECT(self), start, end);
+ PyObject *obj = Proxy_GET_OBJECT(self);
+ if (PyList_Check(obj)) {
+ return PyList_GetSlice(obj, start, end);
+ }
+ else if (PyTuple_Check(obj)) {
+ return PyTuple_GetSlice(obj, start, end);
+ }
+ else {
+ return PySequence_GetSlice(obj, start, end);
+ }
}
static int
wrap_ass_slice(PyObject *self, int i, int j, PyObject *value)
{
- return PySequence_SetSlice(Proxy_GET_OBJECT(self), i, j, value);
+ PyObject *obj = Proxy_GET_OBJECT(self);
+ if (PyList_Check(obj)) {
+ return PyList_SetSlice(obj, i, j, value);
+ }
+ else {
+ return PySequence_SetSlice(obj, i, j, value);
+ }
}
static int
Modified: zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py
===================================================================
--- zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py 2008-06-24 12:18:51 UTC (rev 87705)
+++ zope.proxy/trunk/src/zope/proxy/tests/test_proxy.py 2008-06-24 12:23:50 UTC (rev 87706)
@@ -340,7 +340,73 @@
self.failUnless(a.__class__ is float, a.__class__)
self.failUnless(b is y)
+ def test_getslice(self):
+ # Lists have special slicing bahvior.
+ pList = self.new_proxy([1, 2])
+ self.assertEqual(pList[-1:], [2])
+ self.assertEqual(pList[-2:], [1, 2])
+ self.assertEqual(pList[-3:], [1, 2])
+ # Tuples also have special slicing behavior.
+ pTuple = self.new_proxy((1, 2))
+ self.assertEqual(pTuple[-1:], (2,))
+ self.assertEqual(pTuple[-2:], (1, 2))
+ self.assertEqual(pTuple[-3:], (1, 2))
+
+ # This behavior should be true for all list- and tuple-derived classes.
+ class DerivedList(list):
+
+ def __getslice__(self, start, end, step=None):
+ return (start, end, step)
+
+ pList = self.new_proxy(DerivedList([1, 2]))
+ self.assertEqual(pList[-1:], [2])
+ self.assertEqual(pList[-2:], [1, 2])
+ self.assertEqual(pList[-3:], [1, 2])
+
+ # Another sort of sequence has a different slicing interpretation.
+ class Slicer(object):
+
+ def __len__(self):
+ return 2
+
+ def __getslice__(self, start, end, step=None):
+ return (start, end, step)
+
+ pSlicer = self.new_proxy(Slicer())
+ self.assertEqual(pSlicer[-1:][0], 1)
+ self.assertEqual(pSlicer[-2:][0], 0)
+ # Note that for non-lists and non-tuples the slice is computed
+ # differently
+ self.assertEqual(pSlicer[-3:][0], 1)
+
+ def test_setslice(self):
+ # Lists have special slicing bahvior for assignment as well.
+ pList = self.new_proxy([1, 2])
+ pList[-1:] = [3, 4]
+ self.assertEqual(pList, [1, 3, 4])
+ pList = self.new_proxy([1, 2])
+ pList[-2:] = [3, 4]
+ self.assertEqual(pList, [3, 4])
+ pList = self.new_proxy([1, 2])
+ pList[-3:] = [3, 4]
+ self.assertEqual(pList, [3, 4])
+
+ # This behavior should be true for all list-derived classes.
+ class DerivedList(list):
+ pass
+
+ pList = self.new_proxy(DerivedList([1, 2]))
+ pList[-1:] = [3, 4]
+ self.assertEqual(pList, [1, 3, 4])
+ pList = self.new_proxy(DerivedList([1, 2]))
+ pList[-2:] = [3, 4]
+ self.assertEqual(pList, [3, 4])
+ pList = self.new_proxy(DerivedList([1, 2]))
+ pList[-3:] = [3, 4]
+ self.assertEqual(pList, [3, 4])
+
+
def test_isProxy():
"""
>>> from zope.proxy import ProxyBase, isProxy
More information about the Checkins
mailing list