Author: bree Date: Tue Mar 7 20:50:52 2006 New Revision: 2556 Modified: azax/branches/snowsprint/azaxview.py azax/branches/snowsprint/tests/test_azaxview.py Log: (Florian's patch): handle other HTML entities for IE
Modified: azax/branches/snowsprint/azaxview.py ============================================================================== --- azax/branches/snowsprint/azaxview.py (original) +++ azax/branches/snowsprint/azaxview.py Tue Mar 7 20:50:52 2006 @@ -24,6 +24,10 @@ from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from Products.Five import BrowserView +import htmlentitydefs +import re +_entity_regexp = re.compile(r"&([a-zA-Z]+);") + # -- # Parser implementations # @@ -151,16 +155,19 @@ """ # XML output gets rendered via a page template - render = ViewPageTemplateFile('browser/kukitresponse.pt', content_type='text/xml') - - # XXX test only, hardcoded HTML for the first button of the first demo - ##render = ViewPageTemplateFile('tests/kukitresponse_test.pt', content_type='text/xml') + _render = ViewPageTemplateFile('browser/kukitresponse.pt', content_type='text/xml') - # fix for IE - _render = render + # replace named entities to fix a bug in IE def render(self): + name2codepoint = htmlentitydefs.name2codepoint + def entity_replacer(m): + value = name2codepoint.get(m.group(1)) + if value is None: + return m.group(0) + return "&#%i;" % value + result = self._render() - return result.replace(' ', ' ') + return _entity_regexp.sub(entity_replacer, result) def __init__(self, context, request): BrowserView.__init__(self, context, request) Modified: azax/branches/snowsprint/tests/test_azaxview.py ============================================================================== --- azax/branches/snowsprint/tests/test_azaxview.py (original) +++ azax/branches/snowsprint/tests/test_azaxview.py Tue Mar 7 20:50:52 2006 @@ -1,8 +1,9 @@ # -*- coding: ISO-8859-15 -*- -# Copyright (c) 2005 +# Copyright (c) 2005-2006 # Authors: # Godefroid Chapelle <[EMAIL PROTECTED]> # Tarek Ziad� <[EMAIL PROTECTED]> +# Bal�zs Re� <[EMAIL PROTECTED]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as published @@ -108,7 +109,12 @@ self.assertEqual(params[0].getContent(), content) def test_setHtmlAsChildTextPlusEntity(self): + 'See if non breaking space entity works' self._checkSetHtmlResult(' ') + + def test_setHtmlAsChildTextPlusEntityOthers(self): + 'See if the other HTML entities work as well' + self._checkSetHtmlResult('<p xmlns="http://www.w3.org/1999/xhtml">»Hello world!«</p>') def test_setHtmlAsChildTextOnly(self): self._checkSetHtmlResult('new content') -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins