[z3-five] unicodes and strings in Zope 2.9's ZPT with Zope 3's i18n

Roman Susi rnd at onego.ru
Mon Jul 24 10:03:54 CEST 2006


Maciej Wiśniowski wrote:

>
>>> Is this possible to see that code? I'm very interested in it :)
>>>   
>>
>>
>> I know people sometimes do it, but it makes code unportable and could
>> cause other subtle problems.
>>  
>>
> I've already found some examples of sitecustomize.py that
> change defaultencoding.
> We're using windows and linux so it may be unportable, but
> I think it may be still helpful in some cases.


I do not mean portability in a sense of different OSes -- i mean 
portability between sites.
For example, for the same reasons it is not good to use time.strftime() 
to format your string for email, for example,
because its locale-aware and email messages use strict format for that 
(there is
rfc822.formatdate and maybe some newer function to do it)

>
> Maybe it should be a option in zope.conf that will allow to
> change this behaviour. Firstly I though that
> 'zpublisher-default-encoding' or 'locale' will do the thing...
> but, as you know, it doesn't.
>
>> Unicode is more fun also.
>>  
>>
> But is more difficult especially for begineers and
> especially in Zope2. It's a bit strange to write
> strings with u'. I've never seen this in other languages.
>
Python 3000 will change this. Everything will be Unicode.
Also, if you have a lot of text content, why not separate it from the code?

> So far it seems that we have to use functions like
> yours:
>
> def u(s, encoding="utf-8"):
>    """Convert from UTF8 to Unicode (if needed)"""
>    ...
>
>
> for data stored in attributes and for data
> retrieved from database and be careful to use
> u'...' strings instead of '...'.

Some databases (or at least their Zope adapters) are aware of unicode - 
for example PostgreSQL.

>
>
> Any other clues for Five programmers? :)
>
try to do things and gather experience. There are no coherent top-down 
guides (I mean guides which describe things from concepts to concretics),
only module-oriented documentation (source code, tests, books) and 
problem-oriented cookbook-style docs for zope3... And I think it is very 
important to
study those new concepts of Zope3 which are coming at theoretical level 
and they dive into practical work.

Five is in flux in square, between Zope3 and Zope2...


Regards,
Roman Susi



More information about the z3-five mailing list