Commit f83eb344 authored by Stephan Richter's avatar Stephan Richter

- 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.
parent 5b6f6316
=======
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.
***************************
===========================
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 @@ checking, location brokering, etc.) for which the proxy is responsible.
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.
......@@ -4,4 +4,4 @@ develop = .
[test]
recipe = zc.recipe.testrunner
eggs = zope.proxy
eggs = zope.proxy [test]
##############################################################################
#
# 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,
license='ZPL 2.1',
description='Generic Transparent Proxies',
setup(name='zope.proxy',
version = '3.4.1',
author='Zope Corporation and Contributors',
author_email='zope3-dev@zope.org',
long_description=long_description,
author_email='zope-dev@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',
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 @@ setup(name=name,
]),
],
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,
)
......@@ -629,13 +629,28 @@ wrap_length(PyObject *self)
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
......
......@@ -340,6 +340,72 @@ class ProxyTestCase(unittest.TestCase):
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():
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment