Author: ianb
Date: 2008-11-14 16:10:44 -0700 (Fri, 14 Nov 2008)
New Revision: 3652
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/htmlfill.py
Log:
Added a default encoding when handling mixed str/unicode content
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2008-11-11 22:46:20 UTC (rev 3651)
+++ FormEncode/trunk/docs/news.txt 2008-11-14 23:10:44 UTC (rev 3652)
@@ -8,6 +8,9 @@
* Added :meth:`formencode.api.Invalid.__unicode__`
+* In :mod:`formencode.htmlfill` use a default encoding of utf8 when
+ handling mixed ``str``/``unicode`` content.
+
1.1
---
Modified: FormEncode/trunk/formencode/htmlfill.py
===================================================================
--- FormEncode/trunk/formencode/htmlfill.py 2008-11-11 22:46:20 UTC (rev
3651)
+++ FormEncode/trunk/formencode/htmlfill.py 2008-11-14 23:10:44 UTC (rev
3652)
@@ -166,6 +166,8 @@
<input type="checkbox" name="nice_guy">
"""
+ default_encoding = 'utf8'
+
def __init__(self, defaults, errors=None, use_all_keys=False,
error_formatters=None, error_class='error',
add_attributes=None, listener=None,
@@ -213,9 +215,9 @@
if type(str1) == type(str2):
return str1 == str2
if isinstance(str1, unicode):
- str1 = str1.encode(self.encoding)
+ str1 = str1.encode(self.encoding or self.default_encoding)
else:
- str2 = str2.encode(self.encoding)
+ str2 = str2.encode(self.encoding or self.default_encoding)
return str1 == str2
def close(self):
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs