Author: jab
Date: 2009-02-19 12:13:24 -0700 (Thu, 19 Feb 2009)
New Revision: 3788

Modified:
   FormEncode/trunk/formencode/htmlfill.py
   FormEncode/trunk/tests/test_htmlfill.py
Log:
apply patches from 
https://sourceforge.net/tracker/index.php?func=detail&aid=2616879&group_id=91231&atid=596416
 : [ 2616879 ] explicit empty value in text and password fields
thanks Marius Gedminas


Modified: FormEncode/trunk/formencode/htmlfill.py
===================================================================
--- FormEncode/trunk/formencode/htmlfill.py     2009-02-19 18:18:50 UTC (rev 
3787)
+++ FormEncode/trunk/formencode/htmlfill.py     2009-02-19 19:13:24 UTC (rev 
3788)
@@ -401,7 +401,7 @@
         elif t == 'file':
             pass # don't skip next
         elif t == 'password':
-            if not self.force_defaults:
+            if value is None and not self.force_defaults:
                 value = value or self.get_attr(attrs, 'value', '')
             self.set_attr(attrs, 'value', value)
             self.write_tag('input', attrs, startend)

Modified: FormEncode/trunk/tests/test_htmlfill.py
===================================================================
--- FormEncode/trunk/tests/test_htmlfill.py     2009-02-19 18:18:50 UTC (rev 
3787)
+++ FormEncode/trunk/tests/test_htmlfill.py     2009-02-19 19:13:24 UTC (rev 
3788)
@@ -147,6 +147,13 @@
                                     force_defaults=False)
     assert expected_html == rendered_html, rendered_html
 
+def test_not_force_defaults_text_explicit_empty_value():
+    html = """<input type="text" name="text-1" class="my_text" value="i like 
this text" />"""
+    expected_html = """<input type="text" name="text-1" class="my_text" 
value="" />"""
+    rendered_html = htmlfill.render(html, defaults={"text-1": ""},
+                                    force_defaults=False)
+    assert expected_html == rendered_html, rendered_html
+
 def test_force_defaults_text():
     html = """<input type="text" name="text-1" class="my_text" value="i like 
this text" />"""
     expected_html = """<input type="text" name="text-1" class="my_text" 
value="" />"""
@@ -186,6 +193,13 @@
                                     force_defaults=False)
     assert expected_html == rendered_html, rendered_html
 
+def test_not_force_defaults_password_explicit_empty_value():
+    html = """<input type="password" name="password-1" class="my_password" 
value="i like this password" />"""
+    expected_html = """<input type="password" name="password-1" 
class="my_password" value="" />"""
+    rendered_html = htmlfill.render(html, defaults={"password-1": ""},
+                                    force_defaults=False)
+    assert expected_html == rendered_html, rendered_html
+
 def test_force_defaults_password():
     html = """<input type="password" name="password-1" class="my_password" 
value="i like this password" />"""
     expected_html = """<input type="password" name="password-1" 
class="my_password" value="" />"""


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs

Reply via email to