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
6298b47e
Commit
6298b47e
authored
Mar 12, 1998
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added _getattr.
parent
f28346fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
lib/python/DocumentTemplate/VSEval.py
lib/python/DocumentTemplate/VSEval.py
+16
-5
No files found.
lib/python/DocumentTemplate/VSEval.py
View file @
6298b47e
"""Very Safe Python Expressions
"""
__rcs_id__
=
'$Id: VSEval.py,v 1.1
0 1998/03/10 17:30:4
1 jim Exp $'
__rcs_id__
=
'$Id: VSEval.py,v 1.1
1 1998/03/12 21:37:0
1 jim Exp $'
############################################################################
# Copyright
...
...
@@ -11,7 +11,7 @@ __rcs_id__='$Id: VSEval.py,v 1.10 1998/03/10 17:30:41 jim Exp $'
# rights reserved.
#
############################################################################
__version__
=
'$Revision: 1.1
0
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.1
1
$'
[
11
:
-
2
]
from
string
import
join
,
find
,
split
,
translate
import
sys
,
gparse
,
string
...
...
@@ -85,7 +85,7 @@ class Eval:
# 'manage'. This is a DC specific rule and probably needs to be
# made customizable!
for
name
in
names
:
if
name
[:
1
]
==
'_'
and
name
!=
'_'
and
name
!=
'_vars'
:
if
name
[:
1
]
==
'_'
and
name
not
in
(
'_'
,
'_vars'
,
'_getattr'
)
:
raise
TypeError
,
'illegal name used in expression'
used
=
{}
...
...
@@ -111,18 +111,29 @@ class Eval:
def
eval
(
self
,
mapping
):
d
=
{
'_vars'
:
mapping
}
code
=
self
.
code
globals
=
self
.
globals
for
name
in
self
.
used
:
try
:
d
[
name
]
=
mapping
.
getitem
(
name
,
0
)
except
KeyError
:
pass
except
KeyError
:
if
name
==
'_getattr'
:
d
[
'__builtins__'
]
=
globals
exec
compiled_getattr
in
d
return
eval
(
code
,
self
.
globals
,
d
)
return
eval
(
code
,
globals
,
d
)
def
__call__
(
self
,
**
kw
):
return
eval
(
self
.
code
,
self
.
globals
,
kw
)
compiled_getattr
=
compile
(
'def _getattr(o,n): return __guarded_getattr__(_vars,o,n)'
,
'<string>'
,
'exec'
)
############################################################################
#
# $Log: VSEval.py,v $
# Revision 1.11 1998/03/12 21:37:01 jim
# Added _getattr.
#
# Revision 1.10 1998/03/10 17:30:41 jim
# Newlines (and carriage-returns are now allowed in expressions.
#
...
...
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