[Zope-dev] Re: RFV: Unicode in Zope 2

2005-12-15 Thread Martijn Faassen

Florent Guillaume wrote:

Martijn Faassen wrote:

[snip]
What I'm worried about doing this for old code, but some steps will 
probably become clear during the brainstorming session. Migration 
tools that turn strings in the ZODB into unicode ones magically (with 
the ability to spell out exceptions and encoding)? Tricky...


I'd start by adding some deprecation warnings at the places where 
PlacelessTranslationService (or Localizer for that matter) do their 
workarounds so that normally incompatible types are mixed together.


With the most recent Silva under development, we're not using either 
anymore, so someone else would have to do this.


Where would you put the deprecation warning in PTS? It monkey patches 
the ZPT engine, and in particular its StringIO object, to make sure that 
UTF-8 strings and unicode strings, when finally concatenated at the end 
after page template generation, can actually be concatenated as it will 
first encode the unicode strings to UTF-8. The output of the page 
template will then be UTF-8.


In Zope 2 without this in place, the output of the page template will be 
unicode, and if you put in UTF-8 strings (that aren't just ascii), the 
system will give rise to a UnicodeError when this concatenation takes place.


I guess you could put some detection code in PTS's concatenation 
functionality to see whether anything unicode is mixed with non-ascii 
strings, and in that case output one deprecation warning. I have a 
suspicion that you'll see this warning whenever someone views a page 
template in Plone. :)


Regards,

Martijn
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: RFV: Unicode in Zope 2

2005-12-13 Thread Florent Guillaume

Martijn Faassen wrote:

Jim Fulton wrote:


Martijn Faassen wrote:


[snip]

I'll volunteer to help brainstorm on this, but right now my 
brainstorm is only very dark and full of lightning.




You and I brainstormed this a few months ago.  I think this was on the
list.  I think that, for starters, we would arrange that all Zope 3
views used in Zope 2 would get unicode input.  If you like, I can try
to find this discussion. :)



Ah, right, that is far less scary, indeed. Your post somehow gave me the 
impression you wanted to change the way current Zope 2 does things, but 
if you limit yourself to what happens with Zope 3 stuff in Zope 2, it's 
less scary.


In fact Five already has hacks to make sure that unicode enters 
Five-generated forms. Replacing these hacks with something solid would 
be good.


Anyway, in some basics, Zope 2 does have an approach to unicode for 
*output* that's fairly similar to Zope 3's: if you use unicode 
strings your entire output (including page templates) will be unicode 
(if you don't mix with non-unicode non-ascii strings..). Then the 
response encoding setting is read and everything is transformed once 
to unicode text. Silva uses this. It also struggles to make sure all 
its input is transformed to unicode (among other ways using Formulator).


In Plone, the situation is quite different -- its 
PlacelessTranslationService monkeypatches into the page template 
engine and puts in ways so that you can mix UTF-8 and unicode strings 
together. This then goes on to break assumptions of code that uses 
the page template engine in a unicode-pure environment (which is what 
happened to Silva).



Ick.

I'm not suggesting this is easy.  We may have some messy deprecation
and backward compatibility code.  But we *do* need to solve this problem
eventually, and the solution doesn't get any closer without taking steps.



Yes. I'm optimistic about being able to do this for Five-related stuff. 
If this is eventually going to be people's main development system, then 
we can basically say we've solved the important unicode issues.


What I'm worried about doing this for old code, but some steps will 
probably become clear during the brainstorming session. Migration tools 
that turn strings in the ZODB into unicode ones magically (with the 
ability to spell out exceptions and encoding)? Tricky...


I'd start by adding some deprecation warnings at the places where 
PlacelessTranslationService (or Localizer for that matter) do their 
workarounds so that normally incompatible types are mixed together.


Florent

--
Florent Guillaume, Nuxeo (Paris, France)   CTO, Director of RD
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )