Use OrderedDicts instead of regular dictionaries when returning values from forms.

This commit is contained in:
Lance Stout 2011-12-13 09:00:45 -08:00
parent 9c6dde5d22
commit 116bb6e1b9

View file

@ -159,7 +159,7 @@ class Form(ElementBase):
items = [] items = []
itemsXML = self.xml.findall('{%s}item' % self.namespace) itemsXML = self.xml.findall('{%s}item' % self.namespace)
for itemXML in itemsXML: for itemXML in itemsXML:
item = {} item = OrderedDict()
fieldsXML = itemXML.findall('{%s}field' % FormField.namespace) fieldsXML = itemXML.findall('{%s}field' % FormField.namespace)
for fieldXML in fieldsXML: for fieldXML in fieldsXML:
field = FormField(xml=fieldXML) field = FormField(xml=fieldXML)
@ -168,7 +168,7 @@ class Form(ElementBase):
return items return items
def get_reported(self): def get_reported(self):
fields = {} fields = OrderedDict()
xml = self.xml.findall('{%s}reported/{%s}field' % (self.namespace, xml = self.xml.findall('{%s}reported/{%s}field' % (self.namespace,
FormField.namespace)) FormField.namespace))
for field in xml: for field in xml:
@ -177,7 +177,7 @@ class Form(ElementBase):
return fields return fields
def get_values(self): def get_values(self):
values = {} values = OrderedDict()
fields = self['fields'] fields = self['fields']
for var in fields: for var in fields:
values[var] = fields[var]['value'] values[var] = fields[var]['value']