Re: IUnicodeEncodingConflictResolver moronosity

Marius Gedminas <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <20100922144722.GB26013@platonas>
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

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkyaFvoACgkQkVdEXeem14+HLACghOYe/ZemsrNo7A8A2sJhBPnn
pVUAmgNpc1EE32/LJ6mC9Q9fW8JpSFkt
=Q9M1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.