From: John B. <jb...@dr...> - 2003-11-09 14:35:03
|
Hello, Does SQLObject have any kind of Unicode support? We seem unable to find any, and we've put a few hacks in there to encode Strings as utf-8 before they are placed into the database, and decodes them after they come out. It's nothing special, but I do feel SQLObject is lacking something here. John -- John Baker, (m) 07736393822 http://rant.pointful.info |
From: Bjorn T. <bj...@ya...> - 2004-05-20 13:30:06
|
Hello, I'm using SQLObject in a project where I need unicode support. I would like to be able get and set unicode strings directly to my classes' properties. That is, I want the following to work: >>> class Word(SQLObject): ... value = StringCol() >>> word = Word() >>> word.value = u'unicode string' >>> word.value u'unicode string' I know that I could override _set_value and _get_value in order to get it to work, but I rather not, since that would pollute my code. Would it be possible to add a 'encode/decode hook' similar to _style, which would encode and decode all values set and retrieved from SQLObjects? Or maybe it's possible to solve in some better way? BTW, I'm using the CVS version of SQLObject Regards, Bjorn |
From: Oleg B. <ph...@ma...> - 2004-05-20 13:37:59
|
On Thu, May 20, 2004 at 03:30:05PM +0200, Bjorn Tillenius wrote: > I'm using SQLObject in a project where I need unicode support. I would > > >>> class Word(SQLObject): > ... value = StringCol() Just implemet your own column, say, UnicodeColumn. value = UnicodeColumn() There are many ways you can redefine its behaviour. Using validators, e.g. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Bjorn T. <bj...@ya...> - 2004-05-21 14:01:44
|
On Thu, May 20, 2004 at 05:37:41PM +0400, Oleg Broytmann wrote: > On Thu, May 20, 2004 at 03:30:05PM +0200, Bjorn Tillenius wrote: > > I'm using SQLObject in a project where I need unicode support. I would > > > > >>> class Word(SQLObject): > > ... value = StringCol() > > Just implemet your own column, say, UnicodeColumn. > value = UnicodeColumn() > > There are many ways you can redefine its behaviour. Using validators, > e.g. Thanks, that was what I was looking for. Regards, Bjorn |
From: Ahmed M. A. <ahm...@wa...> - 2005-03-31 12:53:03
|
Hi all, Is there a way to use unicode with sqlobject ? I am working on unicode aware database (postgresql 8 ). Thanks Ahmed MOHAMED ALI |
From: Oleg B. <ph...@ma...> - 2005-03-31 13:49:56
|
On Thu, Mar 31, 2005 at 03:08:30PM +0200, Ahmed MOHAMED ALI wrote: > Is there a way to use unicode with sqlobject ? The latest version (in the Subversion repository) that will be 0.7 has UnicodeColumn. > I am working on unicode aware database (postgresql 8 ). Currently SQLObject does not use unicode-aware drivers. UnicdeCol does all conversions itself. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Ahmed M. A. <ahm...@wa...> - 2005-03-31 14:00:25
|
Thank you Oleg. -----Message d'origine----- De : Oleg Broytmann [mailto:ph...@ph...]De la part de Oleg Broytmann Envoye : jeudi 31 mars 2005 15:50 A : Ahmed MOHAMED ALI Cc : sql...@li... Objet : *** SPAM *** Re: [SQLObject] Unicode support On Thu, Mar 31, 2005 at 03:08:30PM +0200, Ahmed MOHAMED ALI wrote: > Is there a way to use unicode with sqlobject ? The latest version (in the Subversion repository) that will be 0.7 has UnicodeColumn. > I am working on unicode aware database (postgresql 8 ). Currently SQLObject does not use unicode-aware drivers. UnicdeCol does all conversions itself. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Kevin D. <da...@gm...> - 2005-04-06 16:04:40
|
On Mar 31, 2005 9:49 AM, Oleg Broytmann <ph...@ma...> wrote: > On Thu, Mar 31, 2005 at 03:08:30PM +0200, Ahmed MOHAMED ALI wrote: > > Is there a way to use unicode with sqlobject ? > > The latest version (in the Subversion repository) that will be 0.7 > has UnicodeColumn. I'm using SQLObject 0.6.1, and the UnicodeCol is present there (and works just dandy!) Kevin |
From: Ian B. <ia...@co...> - 2003-11-09 18:25:41
|
On Nov 9, 2003, at 8:32 AM, John Baker wrote: > Hello, > > Does SQLObject have any kind of Unicode support? We seem unable to > find any, > and we've put a few hacks in there to encode Strings as utf-8 before > they are > placed into the database, and decodes them after they come out. It's > nothing > special, but I do feel SQLObject is lacking something here. No, there's no specific Unicode support, mostly because I'm not sure how they should best be encoded -- if they should be UTF-8 encoded, if databases have unicode literals, etc. If you wanted to make a validator/converter to do UTF-8 encoding, it might look like: from SQLObject.include import Validator class UTF8Validator(Validator.Validator): def fromPython(self, v, state): # test isinstance(v, unicode)? return v.encode('UTF-8') # strict, loose? def toPython(self, v, state): return v.decode('UTF-8') You could then use something like: class MyThing(SQLObject): unicodeColumn = String(validator=UTFValidator()) I'm not entirely sure about all the details, but this pattern could probably be added to Col.py, and show up either as a subclass of String, or something that could be enabled with a keyword argument. (In that case it probably would be good to include other encodings, especially for legacy databases that don't use UTF-8, and perhaps some clearer handling of strict vs. loose and how to handle non-unicode strings) -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Guenther S. <gs...@sy...> - 2003-11-10 08:17:06
|
On Sun, 2003-11-09 at 15:32, John Baker wrote: Hello, > Does SQLObject have any kind of Unicode support? We seem unable to find any, > and we've put a few hacks in there to encode Strings as utf-8 before they are > placed into the database, and decodes them after they come out. It's nothing > special, but I do feel SQLObject is lacking something here. Which database would you like to use? I've posted a patch which includes support for the PyPgSQL Postgres Adapter some time ago. Unlike other Postgres Adapters, PyPgSQL supports Unicode. I did some tests, and the patch seemed to work, but i haven't used it in production yet. cu /gst |