Changeset 1140 in products


Ignore:
Timestamp:
Jul 23, 2009 10:36:47 AM (15 years ago)
Author:
piv
Message:

fix string encoding issues, update history file, now ready to be released as 0.2.1 version

Location:
qPloneDropDownMenu/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • qPloneDropDownMenu/trunk/HISTORY.txt

    r893 r1140  
     10.2.1 
     2 
     3  * fix string encoding issues during product installation and menu regeneration 
     4    for details: http://talk.quintagroup.com/forums/plone-drop-down-menu/237707814 
     5 
    160.2 
    27 
  • qPloneDropDownMenu/trunk/utils.py

    r372 r1140  
     1# -*- coding: utf-8 -*- 
    12""" Utility functions """ 
    23 
     
    1112from config import PROPERTY_FIELD, PROPERTY_SHEET 
    1213 
     14 
     15TAB_HTML_SNIPPET = """<li id="portaltab-%(id)s" class="plain"> 
     16  <a href="%(url)s" accesskey="t" title="%(desc)s">%(name)s</a> 
     17</li> 
     18""" 
     19 
     20 
    1321def addCSS(container, sheetId, title, csshovering): 
    1422    """ Add DTML Method object to portal root """ 
     
    2129 
    2230    # collect all portal tabs 
    23     context_state = getMultiAdapter((site, site.REQUEST), name=u'plone_context_state') 
     31    context_state = getMultiAdapter((site, site.REQUEST), 
     32                                    name=u'plone_context_state') 
    2433    actions = context_state.actions() 
    25     portal_tabs_view = getMultiAdapter((site, site.REQUEST), name='portal_tabs_view') 
     34    portal_tabs_view = getMultiAdapter((site, site.REQUEST), 
     35                                       name='portal_tabs_view') 
    2636    portal_tabs = portal_tabs_view.topLevelTabs(actions=actions) 
    2737 
    2838    # dump to html 
    29     value = '' 
     39    value = u"" 
     40    enc = portal_props.site_properties.getProperty('default_charset', 'utf-8') 
    3041    for tab in portal_tabs: 
    31         value += '<li id="portaltab-%s" class="plain">\n' % tab['id'] 
    32         value += '  <a href="%s" accesskey="t" title="%s">%s</a>\n' % (tab['url'], tab['description'], tab['name']) 
    33         value += '</li>\n' 
     42        value += TAB_HTML_SNIPPET % {'id': toUnicode(tab['id'], enc), 
     43                                     'url': toUnicode(tab['url'], enc), 
     44                                     'desc': toUnicode(tab['description'], enc), 
     45                                     'name': toUnicode(tab['name'], enc)} 
    3446 
    3547    if not hasattr(portal_props.aq_base, PROPERTY_SHEET): 
    36         portal_props.addPropertySheet(PROPERTY_SHEET, 'DropDown Menu Properties') 
     48        portal_props.addPropertySheet(PROPERTY_SHEET, 
     49                                      'DropDown Menu Properties') 
    3750    ap = getattr(portal_props.aq_base, PROPERTY_SHEET) 
    3851    safeEditProperty(ap, PROPERTY_FIELD, value, 'text') 
     52 
     53def toUnicode(value, enc='utf-8'): 
     54    if isinstance(value, str): 
     55        return value.decode(enc) 
     56    else: 
     57        return value 
Note: See TracChangeset for help on using the changeset viewer.