Skip to content

Commit

Permalink
Adding.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed Feb 5, 2001
1 parent 1e54206 commit 391f26e
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
36 changes: 36 additions & 0 deletions help/Bindings.stx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Script (Python) - Bindings: View/Change Bindings

Description

This view allows you to set "bindings" (associations between a
name and a Zope object) in the context of a single Script.
These names can be used within the Script to refer to objects
outside the script.

Controls

'Context' -- associate a name with the acqusition parent of
the script when it is invoked. The default name for this
binding is "context".

'Container' -- associate a name with the physical parent
container of the script when it is invoked. The default name
for this binding is "container".

'Script' -- associate a name with the script object itself.
There is no default name for this binding.

'Namespace' -- associate a name with the DTML "namespace"
object. When this script is called from DTML, the namespace
name will be bound to the DTML namespace object, otherwise it
will be bound to an empty namespace. There is no default name
for this binding.

'Subpath' -- associate a name with the portion of the URL path
after the script's name if the script is called directly via a
URL. The subpath is represented as a list of strings split a
slash separators if the script is called directly from a URL.
Otherwise, the subpath is an empty list. The default name for
this binding is "traverse_subpath".

'Save Changes' -- saves changes made to the elements of this form.
115 changes: 115 additions & 0 deletions help/PythonScript_edit.stx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Script (Python) - Edit: 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
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
this help system.

Controls

'Title' -- Allows you to specify the Zope title of the script.

'Id' -- Allows you to specify the id of the script.

'Parameter List' -- Enter function parameters for this script
separated by commas. For example: *foo, bar, baz*

Status Elements

'Bound Names' -- the names used by this script for bindings.
You may use these names in the body of the script to refer to
bound elements. The defaults are::

context -- the script's "parent" respective to acquisition.

container -- the script's "parent" respective to containment.

script -- the script object itself.

traverse_subpath -- if the script is called directly from a URL,
this is the portion of the URL path after the script's name,
split at slash separators, into a list of strings. If the script
was not called directly from a URL, this will be an empty list.

Another possible name binding, to the "namespace" object, is
not set by default. If this was set, if the Script was
called from DTML, it would represent the namespace of the
calling DTML object.

More information about bindings can be found by visiting the
help screens of the "Bindings" tab of a Script (Python)
instance.

Buttons and Other Form Elements

'Save Changes' -- saves changes you make to the body, title, or
parameter list.

'Taller'/'Shorter'/'Wider'/'Narrower' -- make the body textarea
taller, shorter, wider, or narrower.

'File' -- upload a file into this Script (Python) instance.

File Upload Details

Files uploaded into a Script (Python) instance may either
consist only of the actual body of the function, or the file
containing the function body may contain at its head a set of
lines starting with "##" which describe bindings, parameters,
and the title. For example, a file uploaded into a Script
(Python) instance might be simply::

return "Hello"

If you upload this file into a Script (Python) instance, the
existing settings (or default settings) for bindings,
parameters, and title will remain.

However, if you wished to, you could develop a Script (Python)
on disk which looked like::

## Script (Python) "foo"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=goop, fudge
##title=
##
return "Fudge was %s, goop was %s" % (fudge, goop)

The lines preceded by "##" are metadata about the Script
(Python) instance which can survive a round trip via FTP or
through the web interface. When these lines are encountered
by the parser after an upload (or webform save), they serve to
*modify* the settings of the Script (Python) instance with the
metadata contained within the blocked area.

Lines beginning with "##" without any spaces after the "##"
are contextually meaningful to the file upload parser. There
are three keywords which can directly follow a "##": "bind",
"parameters", and "title".

The "bind" keyword following a "##" binds a name to a object
in the context this Script (Python) instance's body. For
example, the line "##bind container=goober" binds the name
"goober" to the acquisition parent of the script, allowing you
to refer to "goober" in the script body. Legal objects to
which to bind are: container, context, namespace, script, and
subpath. See the help available from the "bindings" tab of
Script (Python) instances for more details about what bindings
mean.

The "title" keyword following a "##" provides a title to the
script. E.g. "title=A Really Neat Script"

The "parameters" keyword following a "##" provides parameters
to the Script (Python) instance. E.g. "parameters=foo,bar,baz".

18 changes: 18 additions & 0 deletions help/PythonScript_test.stx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Script (Python) - Test: Test A Script (Python)

Description

This view allows you to test a Script (Python) instance.

Controls

If a Script (Python) 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
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
'Parameter' and 'Value' fields have been filled in, and
returns the results in the manage_main frame.

0 comments on commit 391f26e

Please sign in to comment.