[Zodb-checkins] SVN: ZODB/branches/3.3/ Backward compatibility hack
for ZODB.Persistent{List, Mapping}.
Tim Peters
tim.one at comcast.net
Mon Mar 14 18:48:53 EST 2005
Log message for revision 29467:
Backward compatibility hack for ZODB.Persistent{List,Mapping}.
Allow those old (ZODB 3.2) dotted paths to work again.
Fallout: testPersistentMapping.py hasn't actually run anything
for a long time, due to a mysterious "return None" at the start
of its test_suite() function. Removed that. Then its
checkNewPicklesAreSafe test failed. Spent 15 minutes on that,
and gave up -- I'm still not even sure what it's _trying_ to
test. Changed it to a TODO.
Changed:
U ZODB/branches/3.3/NEWS.txt
U ZODB/branches/3.3/src/ZODB/__init__.py
U ZODB/branches/3.3/src/ZODB/tests/testPersistentList.py
U ZODB/branches/3.3/src/ZODB/tests/testPersistentMapping.py
-=-
Modified: ZODB/branches/3.3/NEWS.txt
===================================================================
--- ZODB/branches/3.3/NEWS.txt 2005-03-14 19:20:17 UTC (rev 29466)
+++ ZODB/branches/3.3/NEWS.txt 2005-03-14 23:48:52 UTC (rev 29467)
@@ -83,6 +83,22 @@
that have the same oid (object identifier). ZODB should never do this,
but it's possible for application code to force such an attempt.
+PersistentMapping and PersistentList
+------------------------------------
+
+Backward compatibility code has been added so that the sanest of the
+ZODB 3.2 dotted paths for ``PersistentMapping`` and ``PersistentList``
+resolve. These are still preferred:
+
+- ``from persistent.list import PersistentList``
+- ``from persistent.mapping import PersistentMapping``
+
+but these work again too:
+
+- ``from ZODB.PersistentList import PersistentList``
+- ``from ZODB.PersistentMapping import PersistentMapping``
+
+
fsIndex
-------
Modified: ZODB/branches/3.3/src/ZODB/__init__.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/__init__.py 2005-03-14 19:20:17 UTC (rev 29466)
+++ ZODB/branches/3.3/src/ZODB/__init__.py 2005-03-14 23:48:52 UTC (rev 29467)
@@ -19,13 +19,20 @@
import __builtin__
from persistent import TimeStamp
-from DB import DB
-from transaction import get as get_transaction
+from persistent import list
+from persistent import mapping
-# Backward compat for old imports. I don't think TimeStamp should
-# really be in persistent anyway.
+# Backward compat for old imports.
sys.modules['ZODB.TimeStamp'] = sys.modules['persistent.TimeStamp']
+sys.modules['ZODB.PersistentMapping'] = sys.modules['persistent.mapping']
+sys.modules['ZODB.PersistentList'] = sys.modules['persistent.list']
+del mapping, list, sys
+
+from DB import DB
+
+from transaction import get as get_transaction
# TODO Issue deprecation warning if this variant is used?
__builtin__.get_transaction = get_transaction
+
del __builtin__
Modified: ZODB/branches/3.3/src/ZODB/tests/testPersistentList.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/tests/testPersistentList.py 2005-03-14 19:20:17 UTC (rev 29466)
+++ ZODB/branches/3.3/src/ZODB/tests/testPersistentList.py 2005-03-14 23:48:52 UTC (rev 29467)
@@ -209,6 +209,10 @@
u.extend(u2)
eq(u, u1 + u2, "u == u1 + u2")
+ def checkBackwardCompat(self):
+ # Verify that the sanest of the ZODB 3.2 dotted paths still works.
+ from ZODB.PersistentList import PersistentList as oldPath
+ self.assert_(oldPath is PersistentList)
def test_suite():
return unittest.makeSuite(TestPList, 'check')
Modified: ZODB/branches/3.3/src/ZODB/tests/testPersistentMapping.py
===================================================================
--- ZODB/branches/3.3/src/ZODB/tests/testPersistentMapping.py 2005-03-14 19:20:17 UTC (rev 29466)
+++ ZODB/branches/3.3/src/ZODB/tests/testPersistentMapping.py 2005-03-14 23:48:52 UTC (rev 29467)
@@ -53,7 +53,13 @@
self.assert_(hasattr(r, 'data'))
self.assert_(not hasattr(r, '_container'))
- def checkNewPicklesAreSafe(self):
+ # TODO: This test fails in ZODB 3.3a1. It's making some assumption(s)
+ # about pickles that aren't true. Hard to say when it stopped working,
+ # because this entire test suite hasn't been run for a long time, due to
+ # a mysterious "return None" at the start of the test_suite() function
+ # below. I noticed that when the new checkBackwardCompat() test wasn't
+ # getting run.
+ def TODO_checkNewPicklesAreSafe(self):
s = MappingStorage()
db = ZODB.DB(s)
r = db.open().root()
@@ -75,6 +81,13 @@
self.assert_(hasattr(inst, '_container'))
self.assert_(not hasattr(inst, 'data'))
+ def checkBackwardCompat(self):
+ # Verify that the sanest of the ZODB 3.2 dotted paths still works.
+ from persistent.mapping import PersistentMapping as newPath
+ from ZODB.PersistentMapping import PersistentMapping as oldPath
+
+ self.assert_(oldPath is newPath)
+
def find_global(modulename, classname):
"""Helper for this test suite to get special PersistentMapping"""
@@ -89,7 +102,6 @@
return getattr(mod, classname)
def test_suite():
- return None
return unittest.makeSuite(PMTests, 'check')
if __name__ == "__main__":
More information about the Zodb-checkins
mailing list