[Zope3-dev] Re: Issue 124 in the collector.

Martijn Faassen faassen at infrae.com
Thu Feb 12 14:50:19 EST 2004


Tres Seaver wrote:
> Perhaps we should be lobbying to have Python add a command-line 
> parameter for specifying the default encoding?  /me checks:
> 
>  $ /opt/zc/bin/python -h
>  ...
>  -S     : don't imply 'import site' on initialization
> 
> So, one could run python with -S, and then invoke 
> 'sys.setdefaultencoding("latin-1")' later during Zope startup.

Argh, no, no, really unwise. You'll cut yourself off from the rest
of the Python world during development.

It'd be really bad if I had to force my Python to a certain encoding 
in order for a module to actually work properly, and I couldn't reuse
modules developed under other encoding assumptions..

The way to avoid unicode errors is to religiously unicodize any incoming
data at any boundary with external systems. Then inside your system,
only use unicode (or plain ascii literals, which means no latin 1 characters
in literals).

It's far better to do this right from the start as converting to unicode
is rather hellish. I'm speaking from personal experience; Silva stores
all its information in unicode now, but that wasn't true a year ago.
Zope 2 isn't a very unicode-friendly environment, but friendly enough now.
When I went through this hell last year I made a determination to have 
Zope 3 do it right from the start.

I'm not sure whether we're there yet. There are a few tricky bits with
making sure request data is turned into unicode properly upon input.

Regards,

Martijn




More information about the Zope3-dev mailing list