ZTUtils.Zope.complex_mashal doesn't handle :records
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
New
|
Wishlist
|
Unassigned |
Bug Description
This simple patch allows complex_marshal to return appropriate values for the case when a value is a list of dictionaries. Or at least the test in this code is when the first element of the list is a dictionary. Perhaps this could be tightened.
def complex_
'''Add request marshalling information to a list of name-value pairs.
Names must be strings. Values may be strings,
integers, floats, or DateTimes, and they may also be lists or
namespaces containing these types.
The list is edited in place so that each (name, value) pair
becomes a (name, marshal, value) triple. The middle value is the
request marshalling string. Integer, float, and DateTime values
will have ":int", ":float", or ":date" as their marshal string.
Lists that contain dictionaries will be marshalled using ":records".
Other lists will be flattened, and the elements given ":list" in
addition to their simple marshal string. Dictionaries will be
flattened and marshalled using ":record".
'''
i = len(pairs)
while i > 0:
i = i - 1
k, v = pairs[i]
m = ''
sublist = None
if isinstance(v, StringType):
pass
elif hasattr(v, 'items'):
sublist = []
for sk, sv in v.items():
sm = simple_marshal(sv)
elif isinstance(v, ListType):
sublist = []
if len(v) > 0 and hasattr(v[0], 'items'):
for rec in v:
else:
for sv in v:
else:
m = simple_marshal(v)
if sublist is None:
else:
return pairs
Changed in zope2: | |
importance: | Medium → Wishlist |