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
3b4b2216
Commit
3b4b2216
authored
Feb 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge 2 from evan-script_fix-branch
parent
f51e088d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
13 deletions
+84
-13
lib/python/Products/PythonScripts/__init__.py
lib/python/Products/PythonScripts/__init__.py
+4
-3
lib/python/Products/PythonScripts/help/Bindings.stx
lib/python/Products/PythonScripts/help/Bindings.stx
+1
-1
lib/python/Products/PythonScripts/help/ModuleAccess.stx
lib/python/Products/PythonScripts/help/ModuleAccess.stx
+56
-0
lib/python/Products/PythonScripts/help/PythonScript_edit.stx
lib/python/Products/PythonScripts/help/PythonScript_edit.stx
+4
-4
lib/python/Products/PythonScripts/help/PythonScript_test.stx
lib/python/Products/PythonScripts/help/PythonScript_test.stx
+4
-4
lib/python/Products/PythonScripts/tests/tscripts/try_except.ps
...ython/Products/PythonScripts/tests/tscripts/try_except.ps
+14
-0
lib/python/Products/PythonScripts/version.txt
lib/python/Products/PythonScripts/version.txt
+1
-1
No files found.
lib/python/Products/PythonScripts/__init__.py
View file @
3b4b2216
...
...
@@ -83,8 +83,8 @@
#
##############################################################################
__doc__
=
'''Python Scripts Product Initialization
$Id: __init__.py,v 1.
6 2001/01/10 21:33:06 bri
an Exp $'''
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
$Id: __init__.py,v 1.
7 2001/02/27 17:35:17 ev
an Exp $'''
__version__
=
'$Revision: 1.
7
$'
[
11
:
-
2
]
import
PythonScript
try
:
...
...
@@ -111,4 +111,5 @@ def initialize(context):
)
context
.
registerHelp
()
context
.
registerHelpTitle
(
'Zope Help'
)
context
.
registerHelpTitle
(
'Script (Python)'
)
lib/python/Products/PythonScripts/help/Bindings.stx
View file @
3b4b2216
Script (Python) - Bindings: View/Change
Bindings
Bindings View: View/Change Script
Bindings
Description
...
...
lib/python/Products/PythonScripts/help/ModuleAccess.stx
0 → 100644
View file @
3b4b2216
Allowing Import of Modules
Scripts are able to import a small number of Python modules for
which there are security declarations. These include 'string',
'math', and 'random'. The only way to make other Python modules
available for import is to add security declarations to them in the
filesystem.
MyScriptModules
The simplest way to allow import of a module is to create your own
simple custom Product. To make this Product:
1. Create a subdirectory of your Zope installation's "Products"
directory. The name of the directory doesn't really matter; Let's
call it 'MyScriptModules'.
2. Create a file in this subdirectory called '__init__.py'.
3. Add the following lines to your '__init__.py'::
from Products.PythonScripts.Utility import allow_module, allow_class
from AccessControl import ModuleSecurityInfo, ClassSecurityInfo
from Globals import InitializeClass
4. For each module to which you want to allow access, add
security declarations in '__init__.py'.
Security Declarations
You will need to write different security declarations depending
on how much of a module you want to expose. You should import the
module at the Python command line, and use 'dir(<module_name>)' to
examine its contents. Names starting with underscore ('_') may be
safely ignored. Be wary of dangerous modules, such as 'sys' and
'os', which may be exposed by the module.
You can handle a module, such as 'base64', that contains only safe
functions by writing 'allow_module("module_name")'.
To allow access to only some names, in a module with dangerous
contents, you can write::
ModuleSecurityInfo('module_name').declarePublic('name1',
'name2', ...)
If the module contains a class that you want to use, you will need
to add the following::
from <module_name> import <class>
allow_class(<class>)
Certain modules, such as 'sha', provide extension types instead of
classes. Security declarations typically cannot be added to
extension types, so the only way to use this sort of module is to
write a Python wrapper class, or use External Methods.
lib/python/Products/PythonScripts/help/PythonScript_edit.stx
View file @
3b4b2216
Script (Python) - Edit
: Edit A Script (Python)
Edit View
: Edit A Script (Python)
Description
This view allows you to edit the logic which composes a script
in Python. Script
(Python)
instances execute in a restricted
in Python. Script instances execute in a restricted
context, bounded by your user's privilege level in Zope, and
certain global restrictions of all through-the-web code. For
information about what you "can" and "cannot" do in a Script
(Python)
instance as opposed to non-through-the-web Python,
see the API Reference documentation for "
PythonScript
" in
instance as opposed to non-through-the-web Python,
see the API Reference documentation for "
Script (Python)
" in
this help system.
Controls
...
...
lib/python/Products/PythonScripts/help/PythonScript_test.stx
View file @
3b4b2216
Script (Python) - Test: Test A
Script (Python)
Test View: Test a
Script (Python)
Description
...
...
@@ -6,11 +6,11 @@ Script (Python) - Test: Test A Script (Python)
Controls
If a Script
(Python)
has no parameters, when the "Test" tab is
visited
,
the return value of the script will be presented in
If a Script has no parameters, when the "Test" tab is
visited the return value of the script will be presented in
the manage_main frame.
However, if a Script
(Python)
instance has parameters, a form
However, if a Script instance has parameters, a form
will be presented with fields for "Parameter" and "Value",
changeable on a per-parameter basis. These accept string
values. The 'Run Script' button runs the script after the
...
...
lib/python/Products/PythonScripts/tests/tscripts/try_except.ps
0 → 100644
View file @
3b4b2216
a = 0
b = 1
try:
int('$')
except ValueError:
a = 1
try:
int('1')
except:
b = 0
return a, b
lib/python/Products/PythonScripts/version.txt
View file @
3b4b2216
PythonScripts-1-0-
0
PythonScripts-1-0-
1
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