Author: mtredinnick
Date: 2007-04-01 00:26:26 -0500 (Sun, 01 Apr 2007)
New Revision: 4894
Added:
django/trunk/tests/regressiontests/forms/regressions.py
Modified:
django/trunk/django/newforms/widgets.py
django/trunk/tests/regressiontests/forms/tests.py
Log:
Fixed #3810 -- In newforms, copy attribute dictionaries before modifying them
in place.
Modified: django/trunk/django/newforms/widgets.py
===================================================================
--- django/trunk/django/newforms/widgets.py 2007-04-01 05:25:03 UTC (rev
4893)
+++ django/trunk/django/newforms/widgets.py 2007-04-01 05:26:26 UTC (rev
4894)
@@ -24,7 +24,10 @@
is_hidden = False # Determines whether this corresponds to an
<input type="hidden">.
def __init__(self, attrs=None):
- self.attrs = attrs or {}
+ if attrs is not None:
+ self.attrs = attrs.copy()
+ else:
+ self.attrs = {}
def render(self, name, value, attrs=None):
"""
Added: django/trunk/tests/regressiontests/forms/regressions.py
===================================================================
--- django/trunk/tests/regressiontests/forms/regressions.py
(rev 0)
+++ django/trunk/tests/regressiontests/forms/regressions.py 2007-04-01
05:26:26 UTC (rev 4894)
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# Tests to prevent against recurrences of earlier bugs.
+
+regression_tests = r"""
+It should be possible to re-use attribute dictionaries (#3810)
+>>> from django.newforms import *
+>>> extra_attrs = {'class': 'special'}
+>>> class TestForm(Form):
+... f1 = CharField(max_length=10, widget=TextInput(attrs=extra_attrs))
+... f2 = CharField(widget=TextInput(attrs=extra_attrs))
+>>> TestForm(auto_id=False).as_p()
+u'<p>F1: <input type="text" class="special" name="f1" maxlength="10"
/></p>\n<p>F2: <input type="text" class="special" name="f2" /></p>'
+"""
Modified: django/trunk/tests/regressiontests/forms/tests.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests.py 2007-04-01 05:25:03 UTC
(rev 4893)
+++ django/trunk/tests/regressiontests/forms/tests.py 2007-04-01 05:26:26 UTC
(rev 4894)
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from localflavor import localflavor_tests
+from regressions import regression_tests
form_tests = r"""
>>> from django.newforms import *
@@ -3297,6 +3298,7 @@
__test__ = {
'form_tests': form_tests,
'localflavor': localflavor_tests,
+ 'regressions': regression_tests,
}
if __name__ == "__main__":
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---