Bugs item #1621951, was opened at 2006-12-25 03:58
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1621951&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: SQLObject release (specify)
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: StringCol can't treat other encoding except "ASCII"
Initial Comment:
Hi, I'm Chinese. I'm very like SQLObject. But, I found a encoding bug in the class StringValidator. This class is in the script "col.py". When I input a other encoding string input or output from database with StringCol it will raise a UnicodeEncodeError, because I use GBK encoding to access the string. But in StringValidator Only allow "acsii" encoding.
I have fix it, the new code is below:
import sys
class StringValidator(validators.Validator):
def to_python(self, value, state):
if value is None:
return None
if isinstance(value, unicode):
return value.encode(sys.getdefaultencoding())
return value
def from_python(self, value, state):
if value is None:
return None
if isinstance(value, str):
return value
if isinstance(value, unicode):
return value.encode(sys.getdefaultencoding())
return value
Then, I can use StringCol to access a "GBK" encoding string. Also I must set the default encoding before this:
import sys
reload(sys)
sys.setdefaultencoding("GBK")
Please fix it, Thanks.
SQLObject 0.7.1
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2006-12-25 04:02
Message:
Logged In: NO
It's very surperise that I can't login. My account is gashero, and my
email is "har...@gm...". Thanks!!!!!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1621951&group_id=74338
|