Commit 68e2af9b authored by Thomas Lotze's avatar Thomas Lotze

merging revision 40330 from trunk:

- fixed the API of the pop() method on PersistentDict and PersistentMapping
- no longer try to find pop and popitem on UserDict as all supported
  Python versions have them
- added a test for the default argument of pop()
- added a NEWS.txt entry about pop()
parent c5ab20cd
What's new in ZODB3 3.4.3b1?
==========================
Release date: DD-MMM-2005
Following are dates of internal releases (to support ongoing Zope 2
development) since ZODB 3.4's last public release:
- 3.4.3b1 DD-MMM-2005
PersistentMapping
-----------------
- (3.4.3b1) The ``PersistentMapping`` makes changes by a ``pop()`` method call
persistent now.
What's new in ZODB3 3.4.2?
==========================
Release date: 12-Oct-2005
......
......@@ -73,9 +73,9 @@ class PersistentDict(persistent.Persistent, IterableUserDict):
self._p_changed = True
return self.__super_setdefault(key, failobj)
def pop(self, i):
def pop(self, key, *args):
self._p_changed = True
return self.__super_pop(i)
return self.__super_pop(key, *args)
def popitem(self):
self._p_changed = True
......
......@@ -41,6 +41,8 @@ class PersistentMapping(UserDict, persistent.Persistent):
__super_clear = UserDict.clear
__super_update = UserDict.update
__super_setdefault = UserDict.setdefault
__super_pop = UserDict.pop
__super_popitem = UserDict.popitem
def __delitem__(self, key):
self.__super_delitem(key)
......@@ -66,23 +68,13 @@ class PersistentMapping(UserDict, persistent.Persistent):
self._p_changed = 1
return self.__super_setdefault(key, failobj)
try:
__super_pop = UserDict.pop
except AttributeError:
pass
else:
def pop(self, i):
self._p_changed = 1
return self.__super_pop(i)
try:
__super_popitem = UserDict.popitem
except AttributeError:
pass
else:
def popitem(self):
self._p_changed = 1
return self.__super_popitem()
def pop(self, key, *args):
self._p_changed = 1
return self.__super_pop(key, *args)
def popitem(self):
self._p_changed = 1
return self.__super_popitem()
# __iter__ was added in ZODB 3.4.2, but should have been added long
# before. We could inherit from Python's IterableUserDict instead
......
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
......@@ -136,6 +136,9 @@ class TestPMapping(unittest.TestCase):
else:
raise TestFailed("1 should not be poppable from u2")
x = u2.pop(1, 7)
eq(x, 7, "u2.pop(1, 7) == 7")
# Test popitem
items = u2.items()
......
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