[Zope3-checkins] CVS: Zope3/src/zope/xmlpickle - ppml.py:1.5.4.1
Fred L. Drake, Jr.
fred at zope.com
Thu Sep 11 17:56:00 EDT 2003
Update of /cvs-repository/Zope3/src/zope/xmlpickle
In directory cvs.zope.org:/tmp/cvs-serv22012
Modified Files:
Tag: parentgeddon-branch
ppml.py
Log Message:
add support for True and False
=== Zope3/src/zope/xmlpickle/ppml.py 1.5 => 1.5.4.1 ===
--- Zope3/src/zope/xmlpickle/ppml.py:1.5 Wed Aug 20 10:49:58 2003
+++ Zope3/src/zope/xmlpickle/ppml.py Thu Sep 11 16:55:30 2003
@@ -24,7 +24,7 @@
BINUNICODE, TUPLE, EMPTY_TUPLE, EMPTY_LIST, EMPTY_DICT, LIST, \
DICT, INST, OBJ, GLOBAL, REDUCE, GET, BINGET, LONG_BINGET, PUT, \
BINPUT, LONG_BINPUT, STOP, MARK, BUILD, SETITEMS, SETITEM, \
- BINPERSID, APPEND, APPENDS
+ BINPERSID, APPEND, APPENDS, NEWTRUE, NEWFALSE
from cStringIO import StringIO
@@ -387,16 +387,18 @@
class Persistent(Wrapper):
pass
-class none(Scalar):
- def __init__(self):
- pass
+class NamedScalar(Scalar):
+ def __init__(self, name):
+ self.name = name
def output(self, write, indent=0, strip=0):
- write(' '*indent+'<none/>')
+ write("%s<%s/>" % (' '*indent, self.name))
if not strip:
write('\n')
-none=none()
+none = NamedScalar("none")
+true = NamedScalar("true")
+false = NamedScalar("false")
class Reference(Scalar):
@@ -478,8 +480,25 @@
self.append(none)
dispatch[NONE] = load_none
+ def load_false(self):
+ self.append(false)
+ dispatch[NEWFALSE] = load_false
+
+ def load_true(self):
+ self.append(true)
+ dispatch[NEWTRUE] = load_true
+
def load_int(self):
- self.append(Int(int(self.readline()[:-1])))
+ s = self.readline()[:-1]
+ i = int(s)
+ if s[0] == "0":
+ if i == 1:
+ self.append(true)
+ return
+ elif i == 0 and s != "0": # s == "00"
+ self.append(false)
+ return
+ self.append(Int(i))
dispatch[INT] = load_int
def load_binint(self):
@@ -746,6 +765,12 @@
def none(self, tag, data, NONE_tuple = (NONE, )):
return NONE_tuple
+
+ def true(self, tag, data, TRUE_tuple = (NEWTRUE, )):
+ return TRUE_tuple
+
+ def false(self, tag, data, FALSE_tuple = (NEWFALSE, )):
+ return FALSE_tuple
def long(self, tag, data):
return ((LONG + ''.join(data[2:]).strip().encode('ascii') + 'L\n'), )
More information about the Zope3-Checkins
mailing list