[Checkins] SVN: zope.app.container/branches/3.5/ bugfix backported
from the trunk
Christophe Combelles
ccomb at free.fr
Thu Jun 12 14:23:47 EDT 2008
Log message for revision 87348:
bugfix backported from the trunk
Changed:
U zope.app.container/branches/3.5/CHANGES.txt
U zope.app.container/branches/3.5/src/zope/app/container/browser/tests/test_contents_functional.py
U zope.app.container/branches/3.5/src/zope/app/container/tests/test_containertraversable.py
U zope.app.container/branches/3.5/src/zope/app/container/traversal.py
-=-
Modified: zope.app.container/branches/3.5/CHANGES.txt
===================================================================
--- zope.app.container/branches/3.5/CHANGES.txt 2008-06-12 17:25:43 UTC (rev 87347)
+++ zope.app.container/branches/3.5/CHANGES.txt 2008-06-12 18:23:46 UTC (rev 87348)
@@ -2,6 +2,11 @@
CHANGES
=======
+3.5.4dev (unreleased)
+---------------------
+
+- fixed #238579 / #163149: error with unicode traversing
+
3.5.3 (2007-11-09)
------------------
Modified: zope.app.container/branches/3.5/src/zope/app/container/browser/tests/test_contents_functional.py
===================================================================
--- zope.app.container/branches/3.5/src/zope/app/container/browser/tests/test_contents_functional.py 2008-06-12 17:25:43 UTC (rev 87347)
+++ zope.app.container/branches/3.5/src/zope/app/container/browser/tests/test_contents_functional.py 2008-06-12 18:23:46 UTC (rev 87348)
@@ -337,7 +337,31 @@
body = response.getBody()
self.assert_("cannot be moved" in body)
+ def test_copy_then_delete_with_unicode_name(self):
+ """Tests unicode on object copied then deleted (#238579)."""
+ # create a file with an accentuated unicode name
+ root = self.getRootFolder()
+ root[u'voil\xe0'] = File()
+ transaction.commit()
+
+ # copy the object
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw', form={
+ 'ids' : (u'voil\xe0',),
+ 'container_copy_button' : '' })
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+
+ # delete the object
+ del root[u'voil\xe0']
+ transaction.commit()
+ response = self.publish('/@@contents.html', basic='mgr:mgrpw')
+ self.assertEqual(response.getStatus(), 200)
+
+
def test_suite():
suite = unittest.TestSuite()
Test.layer = AppContainerLayer
Modified: zope.app.container/branches/3.5/src/zope/app/container/tests/test_containertraversable.py
===================================================================
--- zope.app.container/branches/3.5/src/zope/app/container/tests/test_containertraversable.py 2008-06-12 17:25:43 UTC (rev 87347)
+++ zope.app.container/branches/3.5/src/zope/app/container/tests/test_containertraversable.py 2008-06-12 18:23:46 UTC (rev 87348)
@@ -59,6 +59,11 @@
self.failUnless(T.traverse('bar', []) is bar)
self.assertRaises(TraversalError , T.traverse, 'morebar', [])
+ def test_unicode_attr(self):
+ # test traversal with unicode
+ voila = Container()
+ c = Container({}, {u'voil\xe0': voila})
+ self.failUnless(ContainerTraversable(c).traverse(u'voil\xe0', []) is voila)
def test_suite():
Modified: zope.app.container/branches/3.5/src/zope/app/container/traversal.py
===================================================================
--- zope.app.container/branches/3.5/src/zope/app/container/traversal.py 2008-06-12 17:25:43 UTC (rev 87347)
+++ zope.app.container/branches/3.5/src/zope/app/container/traversal.py 2008-06-12 18:23:46 UTC (rev 87348)
@@ -95,7 +95,14 @@
v = container.get(name, _marker)
if v is _marker:
- v = getattr(container, name, _marker)
+ try:
+ # Note that if name is a unicode string, getattr will
+ # implicitly try to encode it using the system
+ # encoding (usually ascii). Failure to encode means
+ # invalid attribute name.
+ v = getattr(container, name, _marker)
+ except UnicodeEncodeError:
+ raise TraversalError(container, name)
if v is _marker:
raise TraversalError(container, name)
More information about the Checkins
mailing list