Python scripts - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Python scripts

Description:

Python scripts. Dragos Chirila. Finsiel Romania. Copenhagen, 25 May 2004. Python overview. it is an interpreted OO programming language ... – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 12
Provided by: adrian52
Category:
Tags: dragos | python | scripts

less

Transcript and Presenter's Notes

Title: Python scripts


1
Python scripts
  • Dragos Chirila
  • Finsiel Romania

Copenhagen, 25 May 2004
2
Python overview
  • it is an interpreted OO programming language
  • it has modules, classes, exceptions, very high
    level dynamic data types, and dynamic typing
  • it is portable it runs on many brands of UNIX,
    on Windows, OS/2, Mac and many other platforms
  • rich set of modules and packages
  • most of Zope is written in Python
  • many resources available at http//www.python.org

3
Zope scripting (I)
  • Zope manages presentation, logic and data with
    objects
  • data Files, Images
  • presentation DTML and Page Templates
  • logic DMTL and scripts (Python and Perl)
  • Scripts objects that encapsulate chunk of code
    written in a programming language
  • Zope comes with Python Scripts, External Methods
  • Perl Scripts separated

4
Zope scripting (II)
  • A script is treated like a method of an object
  • Context the environment in which the script
    executes
  • Scripts can be called
  • from the web, by visiting an URL
  • from any other type of object

5
When to use them
  • Python scripts vs. DTML/ZPT
  • Complicate computations
  • Keep presentation apart from logic
  • Cleaner code
  • When the task becomes complex think about moving
    to External Methods or Python products
  • The only strong point of Python Scripts is the
    fast access to them - from ZMI

6
Python Scripts product
  • The Python Scripts product provides support for
    execution of Python scripts, exposing them as
    callable objects within the Zope
  • In order to create a Python script, from Select
    type to add select Script (Python) and fill
  • Id
  • Title
  • Parameter list
  • Bound Names

7
(No Transcript)
8
(No Transcript)
9
Binding variables (I)
  • Bound names set of variables that are created
    whenever the script is called
  • used to access other Zope objects and scripts and
    are only available in Python scripts
  • the names of the variables are set by default and
    should not be changed

10
Binding variables (II)
  • Context refers to the object (environment) in
    which the script is called - context
  • Container refers to the object (environment) in
    which the script is called container
  • Script refers to the object itself script
  • Namespace is left blank by default
  • Subpath an advanced variable used when the
    script is traversed - traverse_subpath

11
Edit and test a script
  • edit the content of the script object like
    bellow
  • parameters list nameAnonymous
  • body return Hello s! name
  • test the script using the Test tab from ZMI
Write a Comment
User Comments (0)
About PowerShow.com