[Zope-dev] IUnicodeEncodingConflictResolver moronosity

Marius Gedminas marius at gedmin.as
Wed Sep 22 10:47:22 EDT 2010


On Wed, Sep 22, 2010 at 09:34:59AM +0100, Chris Withers wrote:
> On 22/09/2010 03:50, Andreas Jung wrote:
> > I also strongly object such a change in the default behavior.
> 
> I'm sorry, but WHAT?
> 
> > I did a
> > lot of testing of the current implementation and configuration with
> > various browsers and Zope applications and add-ons in order to make the
> > Zope 3 ZPT engine in Zope 2 work out-of-the-box for most applications.

Did "various browsers" include Safari and MSIE, I wonder?  Because those
are the ones causing me pain and UnicodeDecodeErrors.

> A less insane version of that default would be:
> 
> class BasicEncodingConflictResolver(object):
>        implements(IUnicodeEncodingConflictResolver)
> 
>        def resolve(self, context, text, expression):
>            logging.warn('You should register an '
>                         'IUnicodeEncodingConflictResolver that matches '
>                         'your content')
>            encodings = ['utf-8','latin-1']
>            mpc =  getattr(context,'management_page_charset',None)
>            if mpc:
>                encodings.insert(0,mpc)
>            for enc in encodings:
>                try:
>                    return unicode(text,enc)
>                except UnicodeDecorError:
>                    pass
>            return unicode(text,sys.getdefaultencoding(),'replace')

I would prefer this to current implementation.

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3/BlueBream consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20100922/e2ecebfc/attachment.bin 


More information about the Zope-Dev mailing list