From: Oleg B. <ph...@ma...> - 2004-11-30 10:57:53
|
I've got a permission to publish snippets of code from our program. On Tue, Nov 30, 2004 at 01:39:31PM +0300, Oleg Broytmann wrote: > Subclass StrCol, and convert data from unicode to db encoding and > back in its validator. class UnicodeStringValidator(validators.Validator): def fromPython(self, value, state): return value.encode(db_encoding) def toPython(self, value, state): return unicode(value, db_encoding) stringValidator = UnicodeStringValidator() class SOUnicodeStringCol(SOStringCol): def __init__(self, **kw): SOStringCol.__init__(self, **kw) self.validator = validators.All.join(stringValidator, self.validator) class UnicodeStringCol(Col): baseClass = SOUnicodeStringCol Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |