[CMF-checkins] SVN: CMF/trunk/C - added 'decode' function

Yvo Schubbe y.2006_ at wcm-solutions.de
Sun Feb 5 14:24:07 EST 2006


Log message for revision 41565:
  - added 'decode' function
  - made 'utf-8' the initial default_charset
  - changed RSS.py to use 'decode' instead of 'toUnicode'

Changed:
  U   CMF/trunk/CHANGES.txt
  U   CMF/trunk/CMFDefault/profiles/default/properties.xml
  UU  CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py
  U   CMF/trunk/CMFDefault/utils.py

-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt	2006-02-05 19:02:49 UTC (rev 41564)
+++ CMF/trunk/CHANGES.txt	2006-02-05 19:24:06 UTC (rev 41565)
@@ -2,6 +2,9 @@
 
   New Features
 
+    - CMFDefault utils: Added 'decode' function.
+      It decodes values using the default_charset of the site.
+
     - CMFCore.FSPythonScript:  Customized versions now track the "original"
       source from which they were customized, and can present a diff between
       that version and their current source text.

Modified: CMF/trunk/CMFDefault/profiles/default/properties.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/properties.xml	2006-02-05 19:02:49 UTC (rev 41564)
+++ CMF/trunk/CMFDefault/profiles/default/properties.xml	2006-02-05 19:24:06 UTC (rev 41565)
@@ -7,6 +7,6 @@
  <property name="email_from_name"
     type="string">Portal Administrator</property>
  <property name="validate_email" type="boolean">False</property>
- <property name="default_charset" type="string"></property>
+ <property name="default_charset" type="string">utf-8</property>
  <property name="enable_permalink" type="boolean">False</property>
 </site>

Modified: CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py	2006-02-05 19:02:49 UTC (rev 41564)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py	2006-02-05 19:24:06 UTC (rev 41565)
@@ -3,9 +3,8 @@
 from ZTUtils import Batch
 from ZTUtils import LazyFilter
 from Products.CMFCore.utils import getToolByName
-from Products.CMFDefault.utils import toUnicode
+from Products.CMFDefault.utils import decode
 
-ptool = getToolByName(script, 'portal_properties')
 stool = getToolByName(script, 'portal_syndication')
 
 
@@ -42,5 +41,4 @@
                     'url': item.absolute_url() } )
 options['listItemInfos'] = tuple(items)
 
-options = toUnicode( options, ptool.getProperty('default_charset', None) )
-return context.RSS_template(**options)
+return context.RSS_template(**decode(options, script))


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision

Modified: CMF/trunk/CMFDefault/utils.py
===================================================================
--- CMF/trunk/CMFDefault/utils.py	2006-02-05 19:02:49 UTC (rev 41564)
+++ CMF/trunk/CMFDefault/utils.py	2006-02-05 19:24:06 UTC (rev 41565)
@@ -27,6 +27,8 @@
 from ZTUtils.Zope import complex_marshal
 from zope.i18nmessageid import MessageFactory
 
+from Products.CMFCore.utils import getToolByName
+
 from exceptions import IllegalHTML
 
 
@@ -427,5 +429,13 @@
     else:
         return value
 
+security.declarePublic('decode')
+def decode(value, context):
+    """ Decode value using default_charset.
+    """
+    ptool = getToolByName(context, 'portal_properties')
+    default_charset = ptool.getProperty('default_charset', None)
+    return toUnicode(value, default_charset)
+
 security.declarePublic('Message')
 Message = MessageFactory('cmf_default')



More information about the CMF-checkins mailing list