[storm] Latin-1 Character Set

James Henstridge james at jamesh.id.au
Wed Oct 29 00:40:51 GMT 2008


On Wed, Oct 29, 2008 at 4:52 AM, kevin gill <kevin at movieextras.ie> wrote:
> I have been trying out storm and stormcontainer with Zope3 today. It is
> nice and simple. Great product.
>
> I had one problem, that my database is latin-1 (historic reasons) and
> storm is hard-coded to UTF-8. I modified the code in
> databases/postgres.py, line 365'ish to set the connection to LATIN1,
> rather than UTF8. That got me over my problem.
>
> I am posting a note in case anyone else has the same problem in the future.
>
> A better solution might be...
>
> line 329:
>    self._encoding = uri.options.get('charset', 'UTF8')
>
> line  365:
>    raw_connection.set_client_encoding(self._encoding)
>
> line 266:
>    statement = statement.encode(self._database._encoding)
>
> line 282:
>    yield param.encode(self._database._encoding)
>
> And add a &encoding=latin1 to your postgresql uri.

PostgreSQL should reencode input/output between the database encoding
and client encoding for text/character fields.

    http://www.postgresql.org/docs/8.3/static/multibyte.html

Storm sets the client encoding to UTF-8, which should work with any
database encoding (of course, some unicode strings passed to the
database may give errors if they can't be represented, but that is
what you'd expect.  Is this not happening for you?

James.



More information about the storm mailing list