From 4d52c80dd1b4c6aef9407b268ae720eeffd4d962 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Fri, 30 Nov 2007 04:32:25 +0000 Subject: newforms-admin: Merged from trunk up to [6670]. This is just before auto-escaping was checked in. git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6761 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'django/newforms/forms.py') diff --git a/django/newforms/forms.py b/django/newforms/forms.py index b502fb4de2..3e7ab957b0 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -2,7 +2,7 @@ Form classes """ -import copy +from copy import deepcopy from django.utils.datastructures import SortedDict from django.utils.html import escape @@ -21,18 +21,6 @@ def pretty_name(name): name = name[0].upper() + name[1:] return name.replace('_', ' ') -class SortedDictFromList(SortedDict): - "A dictionary that keeps its keys in the order in which they're inserted." - # This is different than django.utils.datastructures.SortedDict, because - # this takes a list/tuple as the argument to __init__(). - def __init__(self, data=None): - if data is None: data = [] - self.keyOrder = [d[0] for d in data] - dict.__init__(self, dict(data)) - - def copy(self): - return SortedDictFromList([(k, copy.deepcopy(v)) for k, v in self.items()]) - class DeclarativeFieldsMetaclass(type): """ Metaclass that converts Field attributes to a dictionary called @@ -50,7 +38,7 @@ class DeclarativeFieldsMetaclass(type): if hasattr(base, 'base_fields'): fields = base.base_fields.items() + fields - attrs['base_fields'] = SortedDictFromList(fields) + attrs['base_fields'] = SortedDict(fields) new_class = type.__new__(cls, name, bases, attrs) if 'media' not in attrs: @@ -79,7 +67,7 @@ class BaseForm(StrAndUnicode): # alter self.fields, we create self.fields here by copying base_fields. # Instances should always modify self.fields; they should not modify # self.base_fields. - self.fields = self.base_fields.copy() + self.fields = deepcopy(self.base_fields) def __unicode__(self): return self.as_table() -- cgit v1.3