diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-11-30 04:32:25 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2007-11-30 04:32:25 +0000 |
| commit | 4d52c80dd1b4c6aef9407b268ae720eeffd4d962 (patch) | |
| tree | 08e126f78db9968aa0830d1f092ed226e09e87b5 /django/newforms/forms.py | |
| parent | 8b3d65e517f3127ff8929ba4caaea32937fb776b (diff) | |
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
Diffstat (limited to 'django/newforms/forms.py')
| -rw-r--r-- | django/newforms/forms.py | 18 |
1 files changed, 3 insertions, 15 deletions
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() |
