API Documentation

Classes

PythonScript

Functions

manage_addPythonScript

Classes

class PythonScript(Script)

Python Scripts contain python code that gets executed when you call the script by:

Python Scripts can contain a "safe" subset of the python language. Python Scripts must be safe because they can be potentially edited by many different users through an insecure medium like the web. The following safety issues drive the need for secure Python Scripts:


Product Constructor

manage_addPythonScript(id, REQUEST=None):

Add a Python script to a folder.


__module__ = __builtin__

Methods

write(text):

Change the script by parsing the text argument into parts. Leading lines that begin with ## are stripped off, and if they are of the form ##name=value, they are used to set meta-data such as the title and parameters. The remainder of the text is set as the body of the Python Script.

ZPythonScriptHTML_editAction(REQUEST, title, params, body):

Change the script's main parameters. This method accepts the following arguments:

REQUEST
The current request.
title
The new value of the Python Script's title. This must be a string.
params
The new value of the Python Script's parameters. Must be a comma seperated list of values in valid python function signature syntax. If it does not contain a valid signature string, a SyntaxError is raised.
body
The new value of the Python Script's body. Must contain valid Python syntax. If it does not contain valid Python syntax, a SyntaxError is raised.

read():

Return the body of the Python Script, with a special comment block prepended. This block contains meta-data in the form of comment lines as expected by the write method.

ZScriptHTML_tryParams():

Return a list of the required parameters with which to test the script.

ZPythonScript_setTitle(title):

Change the script's title. This method accepts one argument, title which is the new value for the script's title and must be a string.

ZPythonScriptHTML_upload(REQUEST, file=):

Pass the text in file to the write method.

ZPythonScript_edit(params, body):

Change the parameters and body of the script. This method accepts two arguments:

params
The new value of the Python Script's parameters. Must be a comma seperated list of values in valid python function signature syntax. If it does not contain a valid signature string, a SyntaxError is raised.
body
The new value of the Python Script's body. Must contain valid Python syntax. If it does not contain valid Python syntax, a SyntaxError is raised.

document_src(REQUEST=None, RESPONSE=None):

Return the text of the read method, with content type text/plain set on the RESPONSE.


Functions

manage_addPythonScript(id, REQUEST=None):

Add a Python script to a folder.