[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/ZPublisher/ DateTime marshalling addendum:

Stefan H. Holek cvs-admin at zope.org
Sat Jun 17 12:30:00 EDT 2006


Log message for revision 68712:
  DateTime marshalling addendum:
  Fixed edge case of attribute name ''.
  

Changed:
  U   Zope/branches/2.9/lib/python/ZPublisher/tests/test_xmlrpc.py
  U   Zope/branches/2.9/lib/python/ZPublisher/xmlrpc.py

-=-
Modified: Zope/branches/2.9/lib/python/ZPublisher/tests/test_xmlrpc.py
===================================================================
--- Zope/branches/2.9/lib/python/ZPublisher/tests/test_xmlrpc.py	2006-06-17 16:09:40 UTC (rev 68711)
+++ Zope/branches/2.9/lib/python/ZPublisher/tests/test_xmlrpc.py	2006-06-17 16:29:57 UTC (rev 68712)
@@ -191,7 +191,20 @@
         response.setBody(body)
         self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, faux._body)
 
+    def test_emptystringattribute(self):
+        # Test an edge case: attribute name '' is possible,
+        # at least in theory.
+        import xmlrpclib
+        body = FauxInstance(_secret='abc')
+        setattr(body, '', True)
+        faux = FauxResponse()
+        response = self._makeOne(faux)
+        response.setBody(body)
+        data, method = xmlrpclib.loads(faux._body)
+        data = data[0]
+        self.assertEqual(data, {'': True})
 
+
 def test_suite():
     return unittest.TestSuite((unittest.makeSuite(XMLRPCResponseTests),))
 

Modified: Zope/branches/2.9/lib/python/ZPublisher/xmlrpc.py
===================================================================
--- Zope/branches/2.9/lib/python/ZPublisher/xmlrpc.py	2006-06-17 16:09:40 UTC (rev 68711)
+++ Zope/branches/2.9/lib/python/ZPublisher/xmlrpc.py	2006-06-17 16:29:57 UTC (rev 68712)
@@ -43,7 +43,8 @@
         # We want to avoid disclosing private attributes.
         # Private attributes are by convention named with
         # a leading underscore character.
-        value = dict([(k, v) for (k, v) in value.__dict__.items() if k[0] != '_'])
+        value = dict([(k, v) for (k, v) in value.__dict__.items()
+                      if k[:1] != '_'])
         self.dump_struct(value, write)
 
 xmlrpclib.Marshaller.dispatch[types.InstanceType] = dump_instance



More information about the Zope-Checkins mailing list