[Zope-dev] IUnicodeEncodingConflictResolver moronosity

Andreas Jung lists at zopyx.com
Wed Sep 22 04:58:33 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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.
> 
> Er, you can't be serious...
> 
> The idea of asking the user agent what encoding is used to encode data
> in the database is like telling an obese person they can have their foot
> amputated in order to lose weight.
> 
> 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')
> 
> 
>> However with the given constraints there will be always applications or
>> bad written code
> 
> PreferredCharsetResolver *is* bad code.
> 
> I'll say it again, 'cos the message doesn't seem to be getting through:
> 
> What on earth do the character sets accepted by the browser have to do
> with the python string encoding used in the data on the server, which up
> until that request, most likely has never been anywhere near that
> browser before?!
> 
>> resolver. That's why it is pluggable.
> 
> Yes, and well documented and advertised too... not!
> 
>> existing resolver smarter and more efficient: +1 for tuning the
>> implementation but the proposed solution above does not solve anything
>> and will break a bunch of apps.
> 
> bull crap.
> 
> Chris

Please calm down - I am not up to reply to a posting written in a tone
that is even far beyond my personal style when ranting on other peoples
crap.

As said: the discussion is documented in some Launchpad ticket.


If you think it is crap then I cam happy to accept that (and I don't
mind much because Zope 2 is not my radar right now). You are committer
and you can fix my crap. Blame me for having written this crap but you
could also blame me for having on this whole Zope 3 ZPT engine
integration :-)

Cheers,
Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJMmcU5AAoJEADcfz7u4AZj1wMLvRQ9riRMebLtqZe4VY9U0SCg
v8S8uS/gZXvBDlDodoNoPurumWGlabCXORD5GRgVZhGiSub1GmTXqslHD5Hro1xf
FeGr3skMlTlAis9xjH3qUuBUbivk5+ebk75ii/jPKJmxRg87a3Gwhi1eFnnCZBTg
AGWzYu5QFmKI/iHgWpYjdQiJ1fS2MtRrisF6JCVuduBJs3kenHAV8huw8/7azv6l
uI/tUQjg2N49s14NWZbIObe/cDY6SkSoiu4ifINTJX68aJxgywVqzGu1aiqR33t3
/j2v347/4TCwdfJGFBopvHLBdoI0WIHA4DB9C2VMuAYO/eOQSrH84gGLqbWeRBku
tfh7KqLa5mulyufXVc3YtgF14rk2kJ5TvRohM4YuR1RFB/0WGU6p0FzD8KZ23pB+
CXk9puJi/FTsIO+eSgDcuPZhoc6ZJoPgA2s03TD+8ghspnWSXU4hbZ2DncYzlDOu
Ss+ri+thcf5APSrvfCb4B7xLq/tW2do=
=yS8z
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lists.vcf
Type: text/x-vcard
Size: 316 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20100922/c4839d66/attachment.vcf 


More information about the Zope-Dev mailing list