Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
36c33ded
Commit
36c33ded
authored
Apr 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve render
parent
41e58b87
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
+24
-18
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+24
-18
No files found.
lib/python/Products/PageTemplates/Expressions.py
View file @
36c33ded
...
@@ -89,14 +89,14 @@ Page Template-specific implementation of TALES, with handlers
...
@@ -89,14 +89,14 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, Python string literals, and paths.
for Python expressions, Python string literals, and paths.
"""
"""
__version__
=
'$Revision: 1.
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
9
$'
[
11
:
-
2
]
import
re
,
sys
import
re
,
sys
from
TALES
import
Engine
,
CompilerError
,
_valid_name
,
NAME_RE
,
\
from
TALES
import
Engine
,
CompilerError
,
_valid_name
,
NAME_RE
,
\
TALESError
,
Undefined
TALESError
,
Undefined
from
string
import
strip
,
split
,
join
,
replace
,
lstrip
from
string
import
strip
,
split
,
join
,
replace
,
lstrip
from
DocumentTemplate.DT_Util
import
TemplateDict
from
DocumentTemplate.DT_Util
import
TemplateDict
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
,
aq_inner
,
aq_parent
_engine
=
None
_engine
=
None
def
getEngine
():
def
getEngine
():
...
@@ -116,16 +116,19 @@ def installHandlers(engine):
...
@@ -116,16 +116,19 @@ def installHandlers(engine):
reg
(
'not'
,
NotExpr
)
reg
(
'not'
,
NotExpr
)
reg
(
'import'
,
ImportExpr
)
reg
(
'import'
,
ImportExpr
)
def
render
(
ob
):
def
render
(
ob
,
ns
):
"""
"""
Calls the object, possibly a document template, or just returns it if
Calls the object, possibly a document template, or just returns it if
not callable. (From DT_Util.py)
not callable. (From DT_Util.py)
"""
"""
if
hasattr
(
ob
,
'__render_with_namespace__'
):
ob
=
ob
.
__render_with_namespace__
(
ns
)
else
:
base
=
aq_base
(
ob
)
base
=
aq_base
(
ob
)
if
callable
(
base
):
if
callable
(
base
):
try
:
try
:
if
getattr
(
base
,
'isDocTemp'
,
0
):
if
getattr
(
base
,
'isDocTemp'
,
0
):
ob
=
ob
(
ob
,
ob
.
REQUEST
)
ob
=
ob
(
aq_parent
(
ob
),
ns
)
else
:
else
:
ob
=
ob
()
ob
=
ob
()
except
AttributeError
,
n
:
except
AttributeError
,
n
:
...
@@ -172,7 +175,7 @@ class PathExpr:
...
@@ -172,7 +175,7 @@ class PathExpr:
self
.
_call_name
=
'_eval'
+
callname
self
.
_call_name
=
'_eval'
+
callname
def
_evalRender
(
self
,
econtext
):
def
_evalRender
(
self
,
econtext
):
return
render
(
self
.
_eval
(
econtext
))
return
render
(
self
.
_eval
(
econtext
)
,
econtext
.
contexts
)
def
_evalIf
(
self
,
econtext
):
def
_evalIf
(
self
,
econtext
):
val
=
self
.
_eval
(
econtext
)
val
=
self
.
_eval
(
econtext
)
...
@@ -180,7 +183,7 @@ class PathExpr:
...
@@ -180,7 +183,7 @@ class PathExpr:
return
Undefined
return
Undefined
if
self
.
modifiers
.
has_key
(
'nocall'
):
if
self
.
modifiers
.
has_key
(
'nocall'
):
return
val
return
val
return
render
(
val
)
return
render
(
val
,
econtext
.
contexts
)
def
_evalExists
(
self
,
econtext
):
def
_evalExists
(
self
,
econtext
):
try
:
try
:
...
@@ -196,7 +199,7 @@ class PathExpr:
...
@@ -196,7 +199,7 @@ class PathExpr:
return
Undefined
return
Undefined
if
self
.
modifiers
.
has_key
(
'nocall'
):
if
self
.
modifiers
.
has_key
(
'nocall'
):
return
val
return
val
return
render
(
val
)
return
render
(
val
,
econtext
.
contexts
)
def
_eval
(
self
,
econtext
):
def
_eval
(
self
,
econtext
):
base
=
self
.
_base
base
=
self
.
_base
...
@@ -225,7 +228,7 @@ class PathExpr:
...
@@ -225,7 +228,7 @@ class PathExpr:
ob
=
ob
[
step
]
ob
=
ob
[
step
]
return
restrictedTraverse
(
ob
,
path
)
return
restrictedTraverse
(
ob
,
path
)
except
(
AttributeError
,
KeyError
,
TypeError
,
IndexError
),
e
:
except
(
AttributeError
,
KeyError
,
TypeError
,
IndexError
),
e
:
raise
Undefined
,
(
e
.
arg
s
,
sys
.
exc_info
()),
sys
.
exc_info
()[
2
]
raise
Undefined
,
(
self
.
_
s
,
sys
.
exc_info
()),
sys
.
exc_info
()[
2
]
def
__call__
(
self
,
econtext
):
def
__call__
(
self
,
econtext
):
return
getattr
(
self
,
self
.
_call_name
)(
econtext
)
return
getattr
(
self
,
self
.
_call_name
)(
econtext
)
...
@@ -436,7 +439,10 @@ def restrictedTraverse(self, path):
...
@@ -436,7 +439,10 @@ def restrictedTraverse(self, path):
if
not
securityManager
.
validate
(
object
,
object
,
name
,
o
):
if
not
securityManager
.
validate
(
object
,
object
,
name
,
o
):
raise
'Unauthorized'
,
name
raise
'Unauthorized'
,
name
else
:
else
:
try
:
o
=
object
[
name
]
o
=
object
[
name
]
except
(
AttributeError
,
TypeError
):
raise
AttributeError
,
name
if
not
securityManager
.
validate
(
object
,
object
,
None
,
o
):
if
not
securityManager
.
validate
(
object
,
object
,
None
,
o
):
raise
'Unauthorized'
,
name
raise
'Unauthorized'
,
name
object
=
o
object
=
o
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment