Commit a0d961df authored by Martijn Pieters's avatar Martijn Pieters

Simplify code by relying on mutablility of the data structures.

parent c8beeeab
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.72 $'[11:-2] __version__='$Revision: 1.73 $'[11:-2]
import re, sys, os, urllib, time, random, cgi, codecs import re, sys, os, urllib, time, random, cgi, codecs
from BaseRequest import BaseRequest from BaseRequest import BaseRequest
...@@ -491,35 +491,27 @@ class HTTPRequest(BaseRequest): ...@@ -491,35 +491,27 @@ class HTTPRequest(BaseRequest):
if mapping_object.has_key(key): if mapping_object.has_key(key):
if flags&RECORDS: if flags&RECORDS:
#Get the list and the last record #Get the list and the last record
#in the list #in the list. reclist is mutable.
reclist = mapping_object[key] reclist = mapping_object[key]
x = reclist[-1] x = reclist[-1]
if not hasattr(x,attr): if not hasattr(x,attr):
#If the attribute does not #If the attribute does not
#exist, setit #exist, setit
if flags&SEQUENCE: item=[item] if flags&SEQUENCE: item=[item]
reclist.remove(x)
setattr(x,attr,item) setattr(x,attr,item)
reclist.append(x)
mapping_object[key] = reclist
else: else:
if flags&SEQUENCE: if flags&SEQUENCE:
# If the attribute is a # If the attribute is a
# sequence, append the item # sequence, append the item
# to the existing attribute # to the existing attribute
reclist.remove(x)
y = getattr(x, attr) y = getattr(x, attr)
y.append(item) y.append(item)
setattr(x, attr, y) setattr(x, attr, y)
reclist.append(x)
mapping_object[key] = reclist
else: else:
# Create a new record and add # Create a new record and add
# it to the list # it to the list
n=record() n=record()
setattr(n,attr,item) setattr(n,attr,item)
reclist.append(n)
mapping_object[key]=reclist
elif flags&RECORD: elif flags&RECORD:
b=mapping_object[key] b=mapping_object[key]
if flags&SEQUENCE: if flags&SEQUENCE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment