Skip to content

Commit

Permalink
make "Unicode Conflict Resolution" available for chamelepn rendering (
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Jul 9, 2020
1 parent 4399637 commit 39b78b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
5.0a3 (unreleased)
------------------

- Make "Unicode Conflict Resolution" available for templates
rendered with ``chameleon``
(`Products.CMFPlone#3145
<https://github.com/plone/Products.CMFPlone/issues/3145>`_).

- New interface ``Products.PageTemplates.interfaces.IZopeAwareEngine``.
It can be used as the "provides" of an adapter registration
to adapt a non ``Zope`` tales engine to an engine to be used
Expand Down
4 changes: 2 additions & 2 deletions src/Products/PageTemplates/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
from zope.pagetemplate.interfaces import IPageTemplateProgram
from zope.tales.expressions import PathExpr
from zope.tales.expressions import SubPathExpr
from zope.tales.tales import Context

from .Expressions import PathIterator
from .Expressions import SecureModuleImporter
from .Expressions import ZopeContext
from .interfaces import IZopeAwareEngine


Expand Down Expand Up @@ -146,7 +146,7 @@ def _compile_zt_expr(type, expression, engine=None, econtext=None):
_compile_zt_expr_node = Static(Symbol(_compile_zt_expr))


class _C2ZContextWrapper(Context):
class _C2ZContextWrapper(ZopeContext):
"""Behaves like "zope" context with vars from "chameleon" context."""
def __init__(self, c_context, attrs):
self.__c_context = c_context
Expand Down
12 changes: 9 additions & 3 deletions src/Products/PageTemplates/tests/testZopePageTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ def testExtractCharsetFromMetaHTTPEquivTag(self):


class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
# BBB The unicode conflict resolution feature is only available
# for the old Zope page template engine!

select_engine = staticmethod(useOldZopeEngine)

def afterSetUp(self):
useOldZopeEngine()
self.select_engine()
zope.component.provideAdapter(DefaultTraversable, (None,))
zope.component.provideAdapter(HTTPCharsets, (None,))
provideUtility(PreferredCharsetResolver,
Expand Down Expand Up @@ -234,6 +234,12 @@ def testDebugFlags(self):
self.assertEqual(zpt.pt_render().startswith('<!--'), True)


class ZPTUnicodeEncodingConflictResolution_chameleon(
ZPTUnicodeEncodingConflictResolution):

select_engine = staticmethod(useChameleonEngine)


class ZopePageTemplateFileTests(ZopeTestCase):

def afterSetUp(self):
Expand Down

0 comments on commit 39b78b1

Please sign in to comment.