[Zope-Checkins] CVS: Packages/Shared/DC/xml - ppml.py:1.17.122.1

Tres Seaver tseaver at zope.com
Fri Nov 26 12:30:31 EST 2004


Update of /cvs-repository/Packages/Shared/DC/xml
In directory cvs.zope.org:/tmp/cvs-serv12454/lib/python/Shared/DC/xml

Modified Files:
      Tag: tseaver-collector_1219-branch
	ppml.py 
Log Message:


  - Patches from issue #1219 (http://zope.org/Collectors/Zope/1219).
    All tests still pass, although there are no tests for ppml.py.


=== Packages/Shared/DC/xml/ppml.py 1.17 => 1.17.122.1 ===
--- Packages/Shared/DC/xml/ppml.py:1.17	Wed Aug 14 17:51:00 2002
+++ Packages/Shared/DC/xml/ppml.py	Fri Nov 26 12:30:31 2004
@@ -167,7 +167,10 @@
         if isinstance(v,Scalar):
             return '%s<%s%s> %s </%s>\n' % (i, name, id, str(v)[:-1], name)
         else:
-            v=v.__str__(indent+2)
+            try:
+                v=v.__str__(indent+2)
+            except TypeError:
+                v=v.__str__()
             return '%s<%s%s>\n%s%s</%s>\n' % (i, name, id, v, i, name)
 
 class Collection:
@@ -215,10 +218,17 @@
     def __len__(self): return len(self._subs)
 
     def append(self, v): self._subs.append(v)
+    def extend(self, v): self._subs.extend(v)
+
+    def _stringify(self, v, indent):
+        try:
+            return v.__str__(indent+2)
+        except TypeError:
+            return v.__str__()
 
     def value(self, indent):
         return string.join(map(
-            lambda v, indent=indent: v.__str__(indent),
+            lambda v, indent=indent: self._stringify(v, indent),
             self._subs),'')
 
 class List(Sequence): pass
@@ -403,12 +413,16 @@
 
     def load_binput(self):
         i = mloads('i' + self.read(1) + '\000\000\000')
-        self.stack[-1].id=self.idprefix+`i`
+        last = self.stack[-1]
+        if getattr(last, 'id', last) is not last:
+            last.id = self.idprefix + `i`
     dispatch[BINPUT] = load_binput
 
     def load_long_binput(self):
         i = mloads('i' + self.read(4))
-        self.stack[-1].id=self.idprefix+`i`
+        last = self.stack[-1]
+        if getattr(last, 'id', last) is not last:
+            last.id = self.idprefix + `i`
     dispatch[LONG_BINPUT] = load_long_binput
 
 



More information about the Zope-Checkins mailing list