products/CPSonFive.old

changeset 18:fd2fa2e28c12

There is now a new IHTTPRequest to IUserPreferredCharsets adapter that forces everything to be ISO-8859-15, which is what we want for CPS.
author lregebro
date Fri, 30 Sep 2005 17:00:32 +0000
parents 2921ae14f632
children 3374f826ead5
files CHANGES __init__.py overrides.zcml
diffstat 3 files changed, 26 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/CHANGES
     1.2 +++ b/CHANGES
     1.3 @@ -3,7 +3,8 @@
     1.4  -
     1.5  New features:
     1.6  ~~~~~~~~~~~~~
     1.7 --
     1.8 +- There is now a new IHTTPRequest to IUserPreferredCharsets adapter that
     1.9 +  forces everything to be ISO-8859-15, which is what we want for CPS.
    1.10  Bug fixes:
    1.11  ~~~~~~~~~~
    1.12  -
     2.1 --- a/__init__.py
     2.2 +++ b/__init__.py
     2.3 @@ -49,17 +49,26 @@
     2.4          message = str(message)
     2.5      return self.context.context.Localizer.default(message)
     2.6  
     2.7 +from zope.i18n.interfaces import IUserPreferredCharsets
     2.8 +from zope.interface import implements
     2.9 +
    2.10 +class ISO15Charset(object):
    2.11 +    # This object implements the selector function for IUserPreferredCharsets
    2.12 +    # but doesn't care what the user prefer, It returns ISO-8859-15 anyway.
    2.13 +    # XXX For support of non-european languages, we need to match this with 
    2.14 +    # the selected UI language somehow. 
    2.15 +    implements(IUserPreferredCharsets)
    2.16 +
    2.17 +    def __init__(self, request):
    2.18 +        self.request = request
    2.19 +        
    2.20 +    def getPreferredCharsets(self):
    2.21 +        '''See interface IUserPreferredCharsets'''
    2.22 +        return ['iso-8859-15']
    2.23  
    2.24  def initialize(context):
    2.25  
    2.26      # Zope3monkey
    2.27      from zope.app.form.browser.itemswidgets import ItemsWidgetBase
    2.28      ItemsWidgetBase.textForValue = textForValue
    2.29 -    
    2.30 -    ## Five monkey
    2.31 -    # Hm? Why? Probably this fix has been pushed into Five by now, because 
    2.32 -    # this edit.pt is exactly the same as Fives...
    2.33 -    #from Products.Five.browser import EditView
    2.34 -    #from Products.Five.pagetemplatefile import FivePageTemplateFile
    2.35 -    #EditView.generated_form = FivePageTemplateFile('edit.pt')
    2.36 -    
    2.37 +    
    2.38 \ No newline at end of file
     3.1 --- a/overrides.zcml
     3.2 +++ b/overrides.zcml
     3.3 @@ -4,5 +4,11 @@
     3.4             > 
     3.5    
     3.6    <include file="form/overrides.zcml" />
     3.7 -    
     3.8 +
     3.9 +  <adapter
    3.10 +      factory=".ISO15Charset"
    3.11 +      for="zope.publisher.interfaces.http.IHTTPRequest"
    3.12 +      provides="zope.i18n.interfaces.IUserPreferredCharsets"
    3.13 +      />
    3.14 +
    3.15  </configure>