Author: mtredinnick
Date: 2008-08-26 16:32:17 -0500 (Tue, 26 Aug 2008)
New Revision: 8601

Modified:
   django/trunk/django/forms/util.py
   django/trunk/django/utils/translation/trans_real.py
   django/trunk/tests/regressiontests/forms/widgets.py
Log:
Fixed #8566 -- Allow safe-strings in the "attrs" parameter to form widgets.


Modified: django/trunk/django/forms/util.py
===================================================================
--- django/trunk/django/forms/util.py   2008-08-26 21:30:15 UTC (rev 8600)
+++ django/trunk/django/forms/util.py   2008-08-26 21:32:17 UTC (rev 8601)
@@ -1,4 +1,4 @@
-from django.utils.html import escape
+from django.utils.html import conditional_escape
 from django.utils.encoding import smart_unicode, StrAndUnicode, force_unicode
 from django.utils.safestring import mark_safe
 
@@ -9,7 +9,7 @@
     XML-style pairs.  It is assumed that the keys do not need to be 
XML-escaped.
     If the passed dictionary is empty, then return an empty string.
     """
-    return u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()])
+    return u''.join([u' %s="%s"' % (k, conditional_escape(v)) for k, v in 
attrs.items()])
 
 class ErrorDict(dict, StrAndUnicode):
     """

Modified: django/trunk/django/utils/translation/trans_real.py
===================================================================
--- django/trunk/django/utils/translation/trans_real.py 2008-08-26 21:30:15 UTC 
(rev 8600)
+++ django/trunk/django/utils/translation/trans_real.py 2008-08-26 21:32:17 UTC 
(rev 8601)
@@ -403,6 +403,7 @@
     date_format = ugettext('DATE_FORMAT')
     datetime_format = ugettext('DATETIME_FORMAT')
     time_format = ugettext('TIME_FORMAT')
+    datetime_full_format = ugettext('DATE_WITH_TIME_FULL')
     if date_format == 'DATE_FORMAT':
         date_format = settings.DATE_FORMAT
     if datetime_format == 'DATETIME_FORMAT':

Modified: django/trunk/tests/regressiontests/forms/widgets.py
===================================================================
--- django/trunk/tests/regressiontests/forms/widgets.py 2008-08-26 21:30:15 UTC 
(rev 8600)
+++ django/trunk/tests/regressiontests/forms/widgets.py 2008-08-26 21:32:17 UTC 
(rev 8601)
@@ -50,6 +50,11 @@
 >>> w.render('email', '', attrs={'class': 'special'})
 u'<input type="text" class="special" name="email" />'
 
+'attrs' can be safe-strings if needed
+>>> w = TextInput(attrs={'onBlur': mark_safe("function('foo')")})
+>>> print w.render('email', '')
+<input onBlur="function('foo')" type="text" name="email" />
+
 # PasswordInput Widget 
############################################################
 
 >>> w = PasswordInput()


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to