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

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
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 )

Reply via email to