Zope Concepts - Python scripts Valentin Baciu Finsiel Romania Tirana, 6 June 2005.

Slides:



Advertisements
Similar presentations
Python Whats in a name? Snake logos and mascot notwithstanding, its named after Monty Pythons Flying Circus Humor-impaired can safely.
Advertisements

director of PythonLabs at Zope Corporation
EIONET Training Zope Page Templates Miruna Bădescu Finsiel Romania Copenhagen, 28 October 2003.
EIONET Training Beginners Zope Course Miruna Bădescu Finsiel Romania Copenhagen, 27 October 2003.
Operating-System Structures
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Write basic.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Chapter 6: Hostile Code Guide to Computer Network Security.
The PHP Story. PHP Story PHP is a programming language. Incorporate(join) sophisticated business logic. Widely used general purpose scripting language.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Plone Großes Seminar Blockseminar SS04 Referentin: Katja Reitz.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
GlueTrack interpreter for S2E beam dynamic simulations Igor Zagorodnov BDGM, DESY
16-1 The World Wide Web The Web An infrastructure of distributed information combined with software that uses networks as a vehicle to exchange that information.
Python Guido van Rossum Sung-Jin Hong SPARCS
1 Python CIS*2450 Advanced Programming Concepts Material for this lecture was developed by Dr. D. Calvert.
Introduction to Programming Peggy Batchelor.
Tutorial 10 Programming with JavaScript
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
FLUKA GUI Status FLUKA Meeting CERN, 10/7/2006.
CERN - IT Department CH-1211 Genève 23 Switzerland t DB Development Tools Benthic SQL Developer Application Express WLCG Service Reliability.
Introduction to CS520/CS596_026 Lecture Two Gordon Tian Fall 2015.
CS4710 Why Progam?. Why learn to program? Utility of programming skills: understand tools modify tools create your own automate repetitive tasks automate.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
CS 127 Introduction to Computer Science. What is a computer?  “A machine that stores and manipulates information under the control of a changeable program”
Ch 1. A Python Q&A Session. Why do people use Python? Software Quality Developer productivity Program portability Support Libraries Component integration.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Basic Concepts for Python Web Development. What Does Make Python Different Batter Software QA Developer Productivity Advance Program Portability Support.
Copyright 2001, ActiveState. Using perl with Zope Andy McKay, ActiveState Python 9 Conference.
Bucharest, 23 February 2005 CHM PTK technologies Adriana Baciu Finsiel Romania.
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Python Programming Unit -1.
Development Environment
CST 1101 Problem Solving Using Computers
Lecture 1-Part 2: Operating-System Structures
ITCS-3190.
Tutorial 10 Programming with JavaScript
Lecture 2 Python Basics.
Web Database Programming Using PHP
Zope Concepts - Zope Page Templates
XML QUESTIONS AND ANSWERS
Ch 1. A Python Q&A Session Bernard Chen 2007.
Platform as a Service.
GLAST Release Manager Automated code compilation via the Release Manager Navid Golpayegani, GSFC/SSAI Overview The Release Manager is a program responsible.
Introduction to Programming the WWW I
Chapter 6 Introduction to Network Operating Systems
PHP / MySQL Introduction
PHP Introduction.
Intro to PHP & Variables
RemoteLaunch - Overview
Henning Schulzrinne Advanced Programming
TRANSLATORS AND IDEs Key Revision Points.
Introduction to Python
Google App Engine Ying Zou 01/24/2016.
Cordova & Cordova Plugin Installation and Management
Download and Installation of code::blocks
IntroductionToPHP Static vs. Dynamic websites
Intro to PHP.
12th Computer Science – Unit 5
PHP an introduction.
Web Servers (IIS and Apache)
Web Application Development Using PHP
Introduction to Python
Presentation transcript:

Zope Concepts - Python scripts Valentin Baciu Finsiel Romania Tirana, 6 June 2005

References for Python “Python has been an important part of Google since the beginning, and remains so as the system grows and evolves. Today dozens of Google engineers use Python…” (Peter Norvig, director of search quality at Google, Inc. )Google, Inc. Name ‘Python ’comes from the Monty Python Flying Circus, no snake involved Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault.

Usage of Python Google (various projects) NASA (several projects) NYSE (one of only three languages "on the floor") Industrial Light & Magic (everything) Yahoo! (Yahoo mail & groups) RealNetworks (function and load testing) RedHat (Linux installation tools) LLNL, Fermilab (steering scientific applications) Zope Corporation (content management) ObjectDomain (embedded Jython in UML tool) Alice project at CMU (accessible 3D graphics) More success stories at

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

Example of usage Here's a simple function written in Python, which sorts a list first for last name and then for first name (double key sort): def sortList(namesList): namesList.sort(lambda x,y: (cmp(x.split()[-1],y.split()[-1]) or cmp(x,y) )) >>> li = [“Elizabeth taylor”,”Bette Davis”,”Hugh Grant”,”C. Grant”] >>> sortList(li) >>> print li  ['Bette Davis', 'C. Grant', 'Hugh Grant', 'Elizabeth taylor']

Zope scripting 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

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 Python Scripts have restricted access to some Python modules

Python Scripts product The Python Scripts product provides support for execution of Python scripts, exposing them as callable objects within the Zope When you create a Python script, from Select type to add… select Script (Python) you can specify: Id Title Parameter list Bound Names Textarea that contains python code

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

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

External Methods When security constraints imposed by scripts, DTML, ZPT come in your way use External Methods Use them if you want –Access to the file system or network –Use Python packages that are not available to restricted scripts (regular expressions) They are stored on the file system (you need access) Reside in the /Extensions directory of the Zope server Must be instantiated in Zope using an External Method form the ‘Select type to add’ list

External Methods in ZMI

External Methods product The External Methods have the following attributes: –Id – the id that will be internally used by Zope –Title – title, optional –Module names – name of the module in the filesystem –Function name – the name of the function from the module Call this function form your DTML, ZPT, Python Scripts methods and make use of the results.