python:test not functional in Page Template code invoked from Five.BrowserView
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 3 |
Won't Fix
|
Undecided
|
Unassigned | ||
zope.tales |
Invalid
|
Wishlist
|
Unassigned |
Bug Description
python:test does not work in view templates that use newer classes like Five.BrowserView.
Marking 'invalid' and suggesting python:cond workarounds e.g
https:/
is really not acceptable.
Unless python:test is to be completely deprecated, and purged from all the books, online tutorials, code shipped with Zope etc. it would be batsh*t insane to ignore this issue. It is very confusing to have what amounts to two different dialects of ZPT bundled in the product.
Here is a patch that should illustrate a fix for this issue - i'm sure there is a better way to write this but i'm not a plone developer.
--- pythonexpr.py 2007-10-30 02:13:44.000000000 +1300
+++ /opt/Plone-
@@ -16,6 +16,9 @@
$Id: pythonexpr.py 30451 2005-05-20 04:54:15Z fdrake $
"""
+from RestrictedPytho
+test = utility_
+
class PythonExpr(object):
def __init__(self, name, expr, engine):
text = '\n'.join(
@@ -49,7 +52,8 @@
if val is not marker:
-
+ #Add this 'oddball' function to the secure 'builtin' namespace explicitly
+ builtins[
return names
Changed in zope3: | |
status: | New → Won't Fix |
Changed in zope.tales: | |
importance: | Undecided → Wishlist |
status: | New → Triaged |
New patch to remove the dependency on RestrictedPython, which was said to be a bad thing on #plone IRC.
--- pythonexpr.py 2007-10-30 02:13:44.000000000 +1300 3.0.6/lib/ python/ zope/tales/ pythonexpr. py 2008-04-30 11:49:31.000000000 +1200
+++ /opt/Plone-
@@ -16,6 +16,15 @@
$Id: pythonexpr.py 30451 2005-05-20 04:54:15Z fdrake $
"""
+def test(*args): e/DT_Util. py expr.splitlines ()) # normalize line endings
val = ExprTypeProxy( vname, val, econtext)
names[vname] = val 'test'] =test
names[ '__builtins_ _'] = builtins
+ #Special 'test' function in ZPT does not exist, and should
+ #be supported for view code compatibility with Document Templates.
+ #see DocumentTemplat
+ l=len(args)
+ for i in range(1, l, 2):
+ if args[i-1]: return args[i]
+ if l%2: return args[-1]
+
class PythonExpr(object):
def __init__(self, name, expr, engine):
text = '\n'.join(
@@ -49,7 +58,8 @@
if val is not marker:
-
+ #Add this 'oddball' function to the secure 'builtin' namespace explicitly
+ builtins[
return names