[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPRequest.py:1.61.6.6
Martijn Pieters
mj@zope.com
Sat, 20 Jul 2002 21:50:27 -0400
Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv8692
Modified Files:
Tag: Zope-2_5-branch
HTTPRequest.py
Log Message:
Merge defaults handling fixes from trunk.
=== Zope/lib/python/ZPublisher/HTTPRequest.py 1.61.6.5 => 1.61.6.6 ===
#insert defaults into form dictionary
if defaults:
- for keys, values in defaults.items():
- if not form.has_key(keys):
+ for key, value in defaults.items():
+ if not form.has_key(key):
# if the form does not have the key,
# set the default
- form[keys]=values
+ form[key]=value
else:
#The form has the key
- if isinstance(values, record):
+ if isinstance(value, record):
# if the key is mapped to a record, get the
# record
- r = form[keys]
- for k, v in values.__dict__.items():
- # loop through the attributes and values
+ r = form[key]
+ for k, v in value.__dict__.items():
+ # loop through the attributes and value
# in the default dictionary
if not hasattr(r, k):
# if the form dictionary doesn't have
# the attribute, set it to the default
setattr(r,k,v)
- form[keys] = r
- elif values == type([]):
- # the key is mapped to a list
- l = form[keys]
- for x in values:
+ form[key] = r
+ elif isinstance(value, lt):
+ # the default value is a list
+ l = form[key]
+ if not isinstance(l, lt):
+ l = [l]
+ for x in value:
# for each x in the list
if isinstance(x, record):
# if the x is a record
@@ -614,9 +616,9 @@
setattr(y, k, v)
else:
# x is not a record
- if not a in l:
- l.append(a)
- form[keys] = l
+ if not x in l:
+ l.append(x)
+ form[key] = l
else:
# The form has the key, the key is not mapped
# to a record or sequence so do nothing