[ZCM] [ZC] 2289/ 1 Request "ZPT implementation in Zope 2.10 breaks backwards compatibility"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Sun, 04 Mar 2007 13:58:05 -0500
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2289 Update (Request) "ZPT implementation in Zope 2.10 breaks backwards compatibility"
Status Pending, Zope/bug medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2289
==============================================================
= Request - Entry #1 by limi on Mar 4, 2007 1:58 pm
The very useful PTProfiler product breaks on Zope 2.10 since some variables are no longer available.
The traceback when trying to use PTProfiler is:
> Traceback (innermost last):
...
> Module Products.PTProfiler.ProfilerPatch, line 22, in __patched_call__
> Module Products.PTProfiler.ProfilerPatch, line 49, in _get_expr
> AttributeError: 'PythonExpr' object has no attribute 'expr'
Philipp von Weitershausen fixed this for me, and said the following:
"""
There are two options for fixing this:
* treating this as a bug of PTProfiler, and subsequently making
PTProfiler aware of the 'text' attribute when running on Zope 2.10
* treating this as a BBB foul of Zope 2.10, and subsequently making
PythonExpr also store the 'expr' attribute (it still needs to store the
'text' attribute because that's what Zope 3's implementation fo
'PythonExpr' wants). See attached patch.
Even though PTProfiler monkeys and that can never be guaranteed to be
forward-compatible, I'm still leaning towards the secound solution.
Anyone with Zope commit privileges is welcome to commit the patch (or
you can open a bug in the collector and assign it to me -- but there's
no guarantee that I can get around it this week).
"""
The patch is very simple, and makes PTProfiler (and any other product relying on the "expr" variable) work again:
Index: lib/python/Products/PageTemplates/ZRPythonExpr.py
===================================================================
--- lib/python/Products/PageTemplates/ZRPythonExpr.py (revision 70946)
+++ lib/python/Products/PageTemplates/ZRPythonExpr.py (working copy)
@@ -28,7 +28,7 @@
_globals['__debug__' ] = __debug__
def __init__(self, name, expr, engine):
- self.text = text = expr.strip().replace('\n', ' ')
+ self.text = self.expr = text = expr.strip().replace('\n', ' ')
code, err, warn, use = compile_restricted_eval(text, str(self))
if err:
raise engine.getCompilerError()('Python expression error:\n%s' %
==============================================================