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
c144bb98
Commit
c144bb98
authored
Jun 10, 2003
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Collector #902: Script recursion broken due to shared globals.
parent
6613529f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
doc/CHANGES.txt
doc/CHANGES.txt
+2
-0
lib/python/Products/PythonScripts/PythonScript.py
lib/python/Products/PythonScripts/PythonScript.py
+14
-15
No files found.
doc/CHANGES.txt
View file @
c144bb98
...
...
@@ -57,6 +57,8 @@ Zope Changes
Bugs Fixed
- Collector #902: recursive Scripts were broken due to shared globals.
- Product initialization would only consult a file named "version.txt"
to read version information. Now it will check version.txt, VERSION.txt
and VERSION.TXT.
...
...
lib/python/Products/PythonScripts/PythonScript.py
View file @
c144bb98
...
...
@@ -17,9 +17,9 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__
=
'$Revision: 1.4
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.4
5
$'
[
11
:
-
2
]
import
sys
,
os
,
traceback
,
re
,
marshal
import
sys
,
os
,
traceback
,
re
,
marshal
,
new
from
Globals
import
DTMLFile
,
MessageDialog
,
package_home
import
AccessControl
,
OFS
,
RestrictedPython
from
OFS.SimpleItem
import
SimpleItem
...
...
@@ -210,7 +210,7 @@ class PythonScript(Script, Historical, Cacheable):
self
.
_compile
()
self
.
_v_change
=
1
elif
self
.
_code
is
None
:
self
.
_v_f
=
None
self
.
_v_f
t
=
None
else
:
self
.
_newfun
(
marshal
.
loads
(
self
.
_code
))
...
...
@@ -224,7 +224,7 @@ class PythonScript(Script, Historical, Cacheable):
self
.
warnings
=
tuple
(
r
[
2
])
if
errors
:
self
.
_code
=
None
self
.
_v_f
=
None
self
.
_v_f
t
=
None
self
.
_setFuncSignature
((),
(),
0
)
# Fix up syntax errors.
filestring
=
' File "<string>",'
...
...
@@ -255,7 +255,8 @@ class PythonScript(Script, Historical, Cacheable):
}
l
=
{}
exec
code
in
g
,
l
self
.
_v_f
=
f
=
l
.
values
()[
0
]
f
=
l
.
values
()[
0
]
self
.
_v_ft
=
(
f
.
func_code
,
g
,
f
.
func_defaults
or
())
return
f
def
_makeFunction
(
self
,
dummy
=
0
):
# CMFCore.FSPythonScript uses dummy arg.
...
...
@@ -263,7 +264,7 @@ class PythonScript(Script, Historical, Cacheable):
self
.
_compile
()
def
_editedBindings
(
self
):
if
getattr
(
self
,
'_v_f'
,
None
)
is
not
None
:
if
getattr
(
self
,
'_v_f
t
'
,
None
)
is
not
None
:
self
.
_makeFunction
()
def
_exec
(
self
,
bound_names
,
args
,
kw
):
...
...
@@ -292,21 +293,19 @@ class PythonScript(Script, Historical, Cacheable):
#__traceback_info__ = bound_names, args, kw, self.func_defaults
f
=
self
.
_v_f
if
f
is
None
:
f
t
=
self
.
_v_ft
if
f
t
is
None
:
__traceback_supplement__
=
(
PythonScriptTracebackSupplement
,
self
)
raise
RuntimeError
,
'%s %s has errors.'
%
(
self
.
meta_type
,
self
.
id
)
fcode
,
g
,
fadefs
=
ft
g
=
g
.
copy
()
if
bound_names
is
not
None
:
# XXX This causes the whole acquisition chain
# to be held by self._v_f. I think we really should
# use new.function() instead, similar to
# CMFCore.FSPythonScript. new.function() takes
# about 8 microseconds on a 1 GHz Athlon. - Shane
f
.
func_globals
.
update
(
bound_names
)
f
.
func_globals
[
'__traceback_supplement__'
]
=
(
g
.
update
(
bound_names
)
g
[
'__traceback_supplement__'
]
=
(
PythonScriptTracebackSupplement
,
self
,
-
1
)
f
=
new
.
function
(
fcode
,
g
,
None
,
fadefs
)
# Execute the function in a new security context.
security
=
getSecurityManager
()
...
...
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