summaryrefslogtreecommitdiff
path: root/django/newforms
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-14 03:29:39 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-09-14 03:29:39 +0000
commit70e5dce3651de6f5494233802a5de609182045df (patch)
treea4a8cf7aec23c3dd061079482db35a2af8e1f5d8 /django/newforms
parent813c48e6eb146a06d40b4d11efebee1d1493665d (diff)
Fixed #3489 -- Added proper deepcopying to form fields so that widget instances get copied as well. Patch from Jonathan Buchanan and insin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6156 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/newforms')
-rw-r--r--django/newforms/fields.py7
-rw-r--r--django/newforms/forms.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/django/newforms/fields.py b/django/newforms/fields.py
index fc816a842b..a2d8afbdeb 100644
--- a/django/newforms/fields.py
+++ b/django/newforms/fields.py
@@ -2,6 +2,7 @@
Field classes
"""
+import copy
import datetime
import re
import time
@@ -100,6 +101,12 @@ class Field(object):
"""
return {}
+ def __deepcopy__(self, memo):
+ result = copy.copy(self)
+ memo[id(self)] = result
+ result.widget = copy.deepcopy(self.widget, memo)
+ return result
+
class CharField(Field):
def __init__(self, max_length=None, min_length=None, *args, **kwargs):
self.max_length, self.min_length = max_length, min_length
diff --git a/django/newforms/forms.py b/django/newforms/forms.py
index 5baf0a079b..ab8729be65 100644
--- a/django/newforms/forms.py
+++ b/django/newforms/forms.py
@@ -31,7 +31,7 @@ class SortedDictFromList(SortedDict):
dict.__init__(self, dict(data))
def copy(self):
- return SortedDictFromList([(k, copy.copy(v)) for k, v in self.items()])
+ return SortedDictFromList([(k, copy.deepcopy(v)) for k, v in self.items()])
class DeclarativeFieldsMetaclass(type):
"""