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
bf30b60e
Commit
bf30b60e
authored
Dec 08, 2000
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow upload with Add, and include binding meta-data in read/write
parent
336a4b28
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
lib/python/Products/PythonScripts/Bindings.py
lib/python/Products/PythonScripts/Bindings.py
+5
-1
lib/python/Products/PythonScripts/PythonScript.py
lib/python/Products/PythonScripts/PythonScript.py
+24
-3
lib/python/Products/PythonScripts/www/pyScriptAdd.dtml
lib/python/Products/PythonScripts/www/pyScriptAdd.dtml
+7
-2
No files found.
lib/python/Products/PythonScripts/Bindings.py
View file @
bf30b60e
...
...
@@ -83,7 +83,7 @@
#
##############################################################################
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
Persistent
,
HTMLFile
,
package_home
...
...
@@ -148,6 +148,10 @@ class NameAssignments:
raise
KeyError
,
name
return
val
def
getAssignedNames
(
self
):
# Returns a copy of the assigned names mapping
return
self
.
_asgns
.
copy
()
def
getAssignedNamesInOrder
(
self
):
# Returns the assigned names in the same order as that of
# self._exprs.
...
...
lib/python/Products/PythonScripts/PythonScript.py
View file @
bf30b60e
...
...
@@ -89,7 +89,7 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__
=
'$Revision: 1.
2
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
3
$'
[
11
:
-
2
]
import
sys
,
os
,
traceback
,
re
from
Globals
import
MessageDialog
,
HTMLFile
,
package_home
...
...
@@ -113,6 +113,10 @@ def manage_addPythonScript(self, id, REQUEST=None):
id
=
str
(
id
)
id
=
self
.
_setObject
(
id
,
PythonScript
(
id
))
if
REQUEST
is
not
None
:
file
=
REQUEST
.
form
.
get
(
'file'
,
None
)
if
file
:
if
type
(
file
)
is
not
type
(
''
):
file
=
file
.
read
()
getattr
(
self
,
id
).
write
(
file
)
try
:
u
=
self
.
DestinationURL
()
except
:
u
=
REQUEST
[
'URL1'
]
REQUEST
.
RESPONSE
.
redirect
(
'%s/%s/manage_main'
%
(
u
,
quote
(
id
)))
...
...
@@ -337,6 +341,8 @@ class PythonScript(Script, Historical):
def write(self, text):
self._validateProxy()
mdata = self._metadata_map()
bindmap = self.getBindingAssignments().getAssignedNames()
bup = 0
st = 0
try:
while 1:
...
...
@@ -371,8 +377,13 @@ class PythonScript(Script, Historical):
self
.
title
=
v
elif
k
==
'parameters'
:
self
.
_params
=
v
elif
k
[:
5
]
==
'bind '
:
bindmap
[
_nice_bind_names
[
k
[
5
:]]]
=
v
bup
=
1
self
.
_body
=
rstrip
(
body
)
if
bup
:
self
.
_setupBindings
(
bindmap
)
self
.
_makeFunction
(
1
)
except
:
LOG
(
self
.
meta_type
,
ERROR
,
'write failed'
,
error
=
sys
.
exc_info
())
...
...
@@ -384,10 +395,14 @@ class PythonScript(Script, Historical):
return
self
.
read
()
def
_metadata_map
(
self
):
return
{
m
=
{
'title'
:
self
.
title
,
'parameters'
:
self
.
_params
,
}
bindmap
=
self
.
getBindingAssignments
().
getAssignedNames
()
for
k
,
v
in
_nice_bind_names
.
items
():
m
[
'bind '
+
k
]
=
bindmap
.
get
(
v
,
''
)
return
m
def
read
(
self
):
# Construct metadata header lines, indented the same as the body.
...
...
@@ -396,7 +411,9 @@ class PythonScript(Script, Historical):
else
:
prefix
=
'##'
hlines
=
[
'%s %s "%s"'
%
(
prefix
,
self
.
meta_type
,
self
.
id
)]
for
kv
in
self
.
_metadata_map
().
items
():
mm
=
self
.
_metadata_map
().
items
()
mm
.
sort
()
for
kv
in
mm
:
hlines
.
append
(
'%s=%s'
%
kv
)
hlines
.
append
(
''
)
return
join
(
hlines
,
'
\
n
'
+
prefix
)
+
'
\
n
'
+
self
.
_body
...
...
@@ -419,3 +436,7 @@ class PythonScript(Script, Historical):
_first_indent
=
re
.
compile
(
'(?m)^ *(?! |$)'
)
_nonempty_line
=
re
.
compile
(
'(?m)^(.*
\
S.*)$
'
)
_nice_bind_names = {'
context
': '
name_context
', '
container
': '
name_container
',
'
script
': '
name_m_self
', '
namespace
': '
name_ns
',
'
subpath
': '
name_subpath
'}
lib/python/Products/PythonScripts/www/pyScriptAdd.dtml
View file @
bf30b60e
...
...
@@ -10,15 +10,20 @@
<P>
Python Scripts allow you to add functionality to Zope by writing
scripts in the Python programming language
that are exposed as callable Zope objects.
that are exposed as callable Zope objects. You may choose to upload
the script from a local file by typing the file name or using the
<i>
Browse
</i>
button.
</P>
<form
action=
"&dtml-URL1;"
method=
"POST"
>
<form
action=
"&dtml-URL1;"
method=
"POST"
enctype=
"multipart/form-data"
>
<input
type=
"hidden"
name=
"manage_addPythonScript:default_method"
value=
""
>
<p>
<strong>
ID:
</strong>
<input
type=
"text"
name=
"id"
size=
"20"
>
</p>
<p>
<strong>
File:
</strong>
<input
type=
"file"
name=
"file"
size=
"25"
>
</p>
<p>
<input
type=
"submit"
value=
"Add and Edit"
name=
"addedit"
>
<input
type=
"submit"
value=
"Cancel"
name=
"manage_workspace:method"
>
</p>
...
...
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