SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
Python
and Zope
An Introduction
Kiran Jonnalagadda
<jace@seacrow.com>
http://jace.seacrow.com/
What kind of a
language is Python?
High Level
& Low Level

High level languages
emphasise developer
productivity; get things
done fast.

Power — Productivity

Low level languages give
you more power, but take
very long to write code
in.

High Level
Lisp
Perl
Python
Java, C#
C++
C
Assembler
Low Level

3
Why
Productivity?
Computers get faster each year.
Humans don’t get faster.
Language that can make programmer
faster makes sense.
Drop in program’s speed is offset by a
faster computer.

4
Types of
Languages
How does the language treat variables?
Type is Strong or Weak
Declaration is Static or Dynamic

5
Strong Typed
Type of variable is
explicit.
Type of variable does not
change depending on
usage.

6

Examples:
In C++, Java or C#:
int n;
n = 0;
n = 0.6;

// valid
// invalid

In Python:
a = 1
b = “hello”
print a + b

# invalid
Weak Typed
Examples:
In shell script (bash):
Type of variable is NOT
explicit.

A=1
B=2
echo $A+$B
# 1+2
echo $((A+B)) # 3

Type of variable depends
on the operation.

In PHP:
$a = 1;
$b = 2;
echo($a + $b); # 3
echo($a . $b); # 12

7
Static Typed
Variable is declared
before use.
Using a variable without
declaring it is a compiletime error.
Type of variable cannot
be changed at run-time.

8

Examples:
In C, C++, Java, C#:
int n;
n = 1; // valid
m = 1; // invalid
Dynamic Typed
Variables need not be
declared before use.

Examples:
In shell script (bash):

However, variables do
not exist until assigned a
value.

A=1
echo $A
echo $B

Reading a non-existent
variable is a run-time
error (varies by language).

9

# 1
# (blank)

In Python:
a = 1
print a
print b

# 1
# (error)
Language Type Matrix
Static Typed

Dynamic Typed

Weak Typed

C

Perl, PHP,
Shell Script

Strong Typed

C++, Java, C#

Python
Capability Matrix
OS Level

GUI

Web

Portable

Perl

Yes

Yes

Yes

Python

Yes

Yes

Yes

Java, C#

Yes

Yes

Yes

VB

Yes

Yes

PHP

Yes

Yes

C++

Yes

Yes

Yes

Yes

C

Yes

Yes

Yes

Yes
Features Matrix
OO

GC

Introspection

ADT*

Perl

Partial

Yes

Partial

Yes

Python

Yes

Yes

Yes

Yes

Java, C#

Yes

Yes

Partial

Yes

VB

Partial

Yes

Partial

PHP

Partial

Yes

Partial

C++

Partial

C
* Advanced Data Types: strings, lists, dictionaries, complex numbers, etc.
What is
Introspection?
Concept introduced by Lisp.
Code can treat code as data.
Can rewrite parts of itself at run-time.
Very powerful if used well.
Python takes it to the extreme.

13
Highlights of
Python
No compile or link steps.
No type declarations.
Object oriented.
High-level data types and operations.
Automatic memory management.
Highly scalable.
Interactive interpreter.

14
Python is all about

Rapid Application
Development
Example Code
Using the Python Interactive Interpreter:
>>> myStr = "Rapid Coils"
>>> myStr.split(" ")[0][:-2].lower() * 3
'rapraprap'
>>> myLst = [1, 2, 3, 4]
>>> myLst.append(5)
>>> "|".join([str(x) for x in myLst])
'1|2|3|4|5'
>>>
Example Code
Dictionaries or hash tables or associative arrays:
>>> myDict = {1:['a','b','c'],2:"abc"}
>>> myDict[3] = ('a','b','c')
>>> myDict.keys()
[1, 2, 3]
>>> myDict['foobar'] = 'barfoo'
>>> myDict.keys()
[1, 2, 3, 'foobar']
>>> myDict
{1: ['a', 'b', 'c'], 2: 'abc', 3: ('a', 'b', 'c'),
'foobar': 'barfoo'}
>>>
Python Classes
Classes are defined using the “class” keyword:
>>> class foo:
...
def __init__(self, text):
...
self.data = text
...
def read(self):
...
return self.data.upper()
...
>>> f = foo("Some text")
>>> f.data
'Some text'
>>> f.read()
'SOME TEXT'
>>>
Inheritance
Classes can derive from other classes:
class Pretty:
def prettyPrint(self, data):
print data.title().strip()
class Names(Pretty):
def __init__(self, value):
self.name = value
def cleanName(self):
self.prettyPrint(self.name)

Multiple inheritance is allowed.
Operator Overloading
class Complex:
def __init__ (self, part1, part2):
self.real = part1
self.im = part2
def __add__ (self, other):
return Complex(self.real + other.real,
self.im + other.im)
>>>
>>>
>>>
>>>
3 5
>>>

a = Complex(1, 2)
b = Complex(2, 3)
c = a + b
print c.real, c.im
Container Model
>>> class foo:
...
pass
...
>>> class bar:
...
pass
...
>>> f = foo()
>>> b = bar()
>>> dir(f)
['__doc__', '__module__']
>>> f.boo = b
>>> dir(f)
['__doc__', '__module__', 'boo']

Observe how items are added to containers.
So that is Python.
What is Zope?
Zope is...
An application built using Python.
Provides a Web server,
A database engine,
A search engine,
A page template language,
Another page template language,
And several standard modules.

23
Visual Studio is to
Windows software

What

development,

Zope is to the Web.
Zope is a Web Application Server.
A framework for building applications with Web-based
interfaces. Zope provides both development and runtime environments.
Web Server:
ZServer
Uses ZServer; Apache not needed.
But Apache can be used in front.
ZPublisher maps URLs to objects.
ZServer does multiple protocols:
HTTP, WebDAV and XML-RPC.
FTP and Secure FTP (SFTP in CVS).

25
Database Engine:
ZODB
Zope Object Database.
Object oriented database.
Can be used independent of Zope.
Fully transparent object persistence.
May be used for either relational or
hierarchical databases, but Zope forces
hierarchical with single-parent.

26
Hierarchical Data Access
Python:

Object

Object.SubObj.Function()

ZServer URL:
site.com/Object/SubObj/Function

The only way to get to
“Function” is via “Object”
and “SubObj.”
Introducing Acquisition...

Function
SubObj
How Acquisition Works

Template

SubSubObj
SubObj
Container

Container.SubObj.SubSubObj.Template is the same
thing as Container.Template, but context differs.
What

Inheritance is to
Classes,

Acquisition is to Instances
and Containers.
ZODB Features
Code need not be database aware.
Includes transactions, unlimited undo.
Storage backend is plug-in driven.
Default: FileStorage.
Others: Directory and BerkeleyDB.
May also be an SQL backend.

30
ZODB with ZEO
ZEO is Zope Enterprise Objects.
One ZODB with multiple Zopes.
Processor usage is usually in logic and
presentation, not database.
ZEO allows load to be distributed
across multiple servers.
Database replication itself is not open
source currently.

31
Search Engine:
ZCatalog
ZCatalog maintains an index of
objects in database.
Is highly configurable.
Multiple ZCatalog instances can be
used together.
No query language; just function calls.

32
Document
Template ML
DTML uses <dtml-command> tags
inserted into HTML.
Common commands: var, if, with, in.
Extensions can add new commands.
DTML is deprecated: difficult to edit
with WYSIWYG editors.

33
Zope Page
Templates
ZPT uses XML namespaces.
Is compatible with WYSIWYG
editors like DreamWeaver.
Enforces separation between logic and
presentation: no code in templates.
Example:

<span tal:replace="here/title”>Title
comes here</span>

34
Zope Page Templates
Box
Slot
Main Body
Slot

Templates define macros and slots using XML
namespaces. Macros fill slots in other templates.
File-system Layout
Zope/
doc/
Extensions/
import/
lib/
python/
Products/
var/
Data.fs
ZServer/

The base folder
Documentation
Individual Python scripts
For importing objects
Libraries
Zope’s extensions to Python
Extensions to Zope
Data folder
The database file
Web server
Example Extension:

Formulator

HTML form construction framework.
Form widgets ⇔ Formulator objects.
Widgets can have validation rules.
Automatic form construction.
Or plugged into a ZPT template.

Painless data validation.

37
Supported Platforms
Supported Operating Systems
Windows

Linux

FreeBSD

OpenBSD

Solaris

Mac OS X

Supported Linux Distributions
Red Hat

Debian

Mandrake

SuSE

Gentoo
Resources
Python: www.python.org
Zope: www.zope.org
The Indian Zope and Python User’s Group

groups.yahoo.com/group/izpug

Contenu connexe

Tendances

WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoadwebuploader
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroadJim Jones
 
web programming Unit VI PPT by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Malothweb programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT by Bhavsingh MalothBhavsingh Maloth
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Chicago Hadoop Users Group
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyBozhidar Bozhanov
 
Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java ProgrammersMike Bowler
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformHoward Mansell
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming PatternsVasil Remeniuk
 

Tendances (20)

WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
web programming Unit VI PPT by Bhavsingh Maloth
web programming Unit VI PPT  by Bhavsingh Malothweb programming Unit VI PPT  by Bhavsingh Maloth
web programming Unit VI PPT by Bhavsingh Maloth
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416
 
C++vs java
C++vs javaC++vs java
C++vs java
 
Ruby
RubyRuby
Ruby
 
ApacheCon09: Avro
ApacheCon09: AvroApacheCon09: Avro
ApacheCon09: Avro
 
Python made easy
Python made easy Python made easy
Python made easy
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 
Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java Programmers
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical Platform
 
Programming in hack
Programming in hackProgramming in hack
Programming in hack
 
Java 8 by example!
Java 8 by example!Java 8 by example!
Java 8 by example!
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 

Similaire à Python and Zope: An introduction (May 2004)

JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdprat0ham
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersGlenn De Backer
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming LanguageYLTO
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZeeshan MIrza
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: LegacyVictor_Cr
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experiencedzynofustechnology
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovSvetlin Nakov
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programmingChetan Giridhar
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypseelliando dias
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudyYusuke Ando
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part IIEugene Lazutkin
 

Similaire à Python and Zope: An introduction (May 2004) (20)

JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
Java basic
Java basicJava basic
Java basic
 
Unit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rdUnit 1 Core Java for Compter Science 3rd
Unit 1 Core Java for Compter Science 3rd
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopers
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENTJava 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENT
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
 
Tutorial on-python-programming
Tutorial on-python-programmingTutorial on-python-programming
Tutorial on-python-programming
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
20100730 phpstudy
20100730 phpstudy20100730 phpstudy
20100730 phpstudy
 
Exciting JavaScript - Part II
Exciting JavaScript - Part IIExciting JavaScript - Part II
Exciting JavaScript - Part II
 

Plus de Kiran Jonnalagadda

AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)Kiran Jonnalagadda
 
The medium without the message (April 2008)
The medium without the message (April 2008)The medium without the message (April 2008)
The medium without the message (April 2008)Kiran Jonnalagadda
 
Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Kiran Jonnalagadda
 
Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Kiran Jonnalagadda
 
What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)Kiran Jonnalagadda
 
On blogging as a career (June 2005)
On blogging as a career (June 2005)On blogging as a career (June 2005)
On blogging as a career (June 2005)Kiran Jonnalagadda
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Kiran Jonnalagadda
 
Human database relations (March 2004)
Human database relations (March 2004)Human database relations (March 2004)
Human database relations (March 2004)Kiran Jonnalagadda
 
The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)Kiran Jonnalagadda
 
Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Kiran Jonnalagadda
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)Kiran Jonnalagadda
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Kiran Jonnalagadda
 
e-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductione-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductionKiran Jonnalagadda
 

Plus de Kiran Jonnalagadda (17)

AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)AirJaldi photo rout (April 2008)
AirJaldi photo rout (April 2008)
 
The medium without the message (April 2008)
The medium without the message (April 2008)The medium without the message (April 2008)
The medium without the message (April 2008)
 
Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)Understanding technology in e-governance (December 2007)
Understanding technology in e-governance (December 2007)
 
Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)Namma service cash tracking system (January 2007)
Namma service cash tracking system (January 2007)
 
What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)What ails the Sarai Reader List? (August 2005)
What ails the Sarai Reader List? (August 2005)
 
On blogging as a career (June 2005)
On blogging as a career (June 2005)On blogging as a career (June 2005)
On blogging as a career (June 2005)
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)
 
Human database relations (March 2004)
Human database relations (March 2004)Human database relations (March 2004)
Human database relations (March 2004)
 
The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)The technology of the Human Protein Reference Database (draft, 2003)
The technology of the Human Protein Reference Database (draft, 2003)
 
Introduction to Plone (November 2003)
Introduction to Plone (November 2003)Introduction to Plone (November 2003)
Introduction to Plone (November 2003)
 
ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)ZODB, the Zope Object Database (May 2003)
ZODB, the Zope Object Database (May 2003)
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)Some dope on Zope (Jan 2002, Bangalore LUG)
Some dope on Zope (Jan 2002, Bangalore LUG)
 
User Management with LastUser
User Management with LastUserUser Management with LastUser
User Management with LastUser
 
Sustainability and bit-rot
Sustainability and bit-rotSustainability and bit-rot
Sustainability and bit-rot
 
e-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introductione-Governance in Karnataka: An introduction
e-Governance in Karnataka: An introduction
 
Cyberpunk Sci-Fi
Cyberpunk Sci-FiCyberpunk Sci-Fi
Cyberpunk Sci-Fi
 

Dernier

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Dernier (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Python and Zope: An introduction (May 2004)

  • 1. Python and Zope An Introduction Kiran Jonnalagadda <jace@seacrow.com> http://jace.seacrow.com/
  • 2. What kind of a language is Python?
  • 3. High Level & Low Level High level languages emphasise developer productivity; get things done fast. Power — Productivity Low level languages give you more power, but take very long to write code in. High Level Lisp Perl Python Java, C# C++ C Assembler Low Level 3
  • 4. Why Productivity? Computers get faster each year. Humans don’t get faster. Language that can make programmer faster makes sense. Drop in program’s speed is offset by a faster computer. 4
  • 5. Types of Languages How does the language treat variables? Type is Strong or Weak Declaration is Static or Dynamic 5
  • 6. Strong Typed Type of variable is explicit. Type of variable does not change depending on usage. 6 Examples: In C++, Java or C#: int n; n = 0; n = 0.6; // valid // invalid In Python: a = 1 b = “hello” print a + b # invalid
  • 7. Weak Typed Examples: In shell script (bash): Type of variable is NOT explicit. A=1 B=2 echo $A+$B # 1+2 echo $((A+B)) # 3 Type of variable depends on the operation. In PHP: $a = 1; $b = 2; echo($a + $b); # 3 echo($a . $b); # 12 7
  • 8. Static Typed Variable is declared before use. Using a variable without declaring it is a compiletime error. Type of variable cannot be changed at run-time. 8 Examples: In C, C++, Java, C#: int n; n = 1; // valid m = 1; // invalid
  • 9. Dynamic Typed Variables need not be declared before use. Examples: In shell script (bash): However, variables do not exist until assigned a value. A=1 echo $A echo $B Reading a non-existent variable is a run-time error (varies by language). 9 # 1 # (blank) In Python: a = 1 print a print b # 1 # (error)
  • 10. Language Type Matrix Static Typed Dynamic Typed Weak Typed C Perl, PHP, Shell Script Strong Typed C++, Java, C# Python
  • 11. Capability Matrix OS Level GUI Web Portable Perl Yes Yes Yes Python Yes Yes Yes Java, C# Yes Yes Yes VB Yes Yes PHP Yes Yes C++ Yes Yes Yes Yes C Yes Yes Yes Yes
  • 13. What is Introspection? Concept introduced by Lisp. Code can treat code as data. Can rewrite parts of itself at run-time. Very powerful if used well. Python takes it to the extreme. 13
  • 14. Highlights of Python No compile or link steps. No type declarations. Object oriented. High-level data types and operations. Automatic memory management. Highly scalable. Interactive interpreter. 14
  • 15. Python is all about Rapid Application Development
  • 16. Example Code Using the Python Interactive Interpreter: >>> myStr = "Rapid Coils" >>> myStr.split(" ")[0][:-2].lower() * 3 'rapraprap' >>> myLst = [1, 2, 3, 4] >>> myLst.append(5) >>> "|".join([str(x) for x in myLst]) '1|2|3|4|5' >>>
  • 17. Example Code Dictionaries or hash tables or associative arrays: >>> myDict = {1:['a','b','c'],2:"abc"} >>> myDict[3] = ('a','b','c') >>> myDict.keys() [1, 2, 3] >>> myDict['foobar'] = 'barfoo' >>> myDict.keys() [1, 2, 3, 'foobar'] >>> myDict {1: ['a', 'b', 'c'], 2: 'abc', 3: ('a', 'b', 'c'), 'foobar': 'barfoo'} >>>
  • 18. Python Classes Classes are defined using the “class” keyword: >>> class foo: ... def __init__(self, text): ... self.data = text ... def read(self): ... return self.data.upper() ... >>> f = foo("Some text") >>> f.data 'Some text' >>> f.read() 'SOME TEXT' >>>
  • 19. Inheritance Classes can derive from other classes: class Pretty: def prettyPrint(self, data): print data.title().strip() class Names(Pretty): def __init__(self, value): self.name = value def cleanName(self): self.prettyPrint(self.name) Multiple inheritance is allowed.
  • 20. Operator Overloading class Complex: def __init__ (self, part1, part2): self.real = part1 self.im = part2 def __add__ (self, other): return Complex(self.real + other.real, self.im + other.im) >>> >>> >>> >>> 3 5 >>> a = Complex(1, 2) b = Complex(2, 3) c = a + b print c.real, c.im
  • 21. Container Model >>> class foo: ... pass ... >>> class bar: ... pass ... >>> f = foo() >>> b = bar() >>> dir(f) ['__doc__', '__module__'] >>> f.boo = b >>> dir(f) ['__doc__', '__module__', 'boo'] Observe how items are added to containers.
  • 22. So that is Python. What is Zope?
  • 23. Zope is... An application built using Python. Provides a Web server, A database engine, A search engine, A page template language, Another page template language, And several standard modules. 23
  • 24. Visual Studio is to Windows software What development, Zope is to the Web. Zope is a Web Application Server. A framework for building applications with Web-based interfaces. Zope provides both development and runtime environments.
  • 25. Web Server: ZServer Uses ZServer; Apache not needed. But Apache can be used in front. ZPublisher maps URLs to objects. ZServer does multiple protocols: HTTP, WebDAV and XML-RPC. FTP and Secure FTP (SFTP in CVS). 25
  • 26. Database Engine: ZODB Zope Object Database. Object oriented database. Can be used independent of Zope. Fully transparent object persistence. May be used for either relational or hierarchical databases, but Zope forces hierarchical with single-parent. 26
  • 27. Hierarchical Data Access Python: Object Object.SubObj.Function() ZServer URL: site.com/Object/SubObj/Function The only way to get to “Function” is via “Object” and “SubObj.” Introducing Acquisition... Function SubObj
  • 28. How Acquisition Works Template SubSubObj SubObj Container Container.SubObj.SubSubObj.Template is the same thing as Container.Template, but context differs.
  • 29. What Inheritance is to Classes, Acquisition is to Instances and Containers.
  • 30. ZODB Features Code need not be database aware. Includes transactions, unlimited undo. Storage backend is plug-in driven. Default: FileStorage. Others: Directory and BerkeleyDB. May also be an SQL backend. 30
  • 31. ZODB with ZEO ZEO is Zope Enterprise Objects. One ZODB with multiple Zopes. Processor usage is usually in logic and presentation, not database. ZEO allows load to be distributed across multiple servers. Database replication itself is not open source currently. 31
  • 32. Search Engine: ZCatalog ZCatalog maintains an index of objects in database. Is highly configurable. Multiple ZCatalog instances can be used together. No query language; just function calls. 32
  • 33. Document Template ML DTML uses <dtml-command> tags inserted into HTML. Common commands: var, if, with, in. Extensions can add new commands. DTML is deprecated: difficult to edit with WYSIWYG editors. 33
  • 34. Zope Page Templates ZPT uses XML namespaces. Is compatible with WYSIWYG editors like DreamWeaver. Enforces separation between logic and presentation: no code in templates. Example: <span tal:replace="here/title”>Title comes here</span> 34
  • 35. Zope Page Templates Box Slot Main Body Slot Templates define macros and slots using XML namespaces. Macros fill slots in other templates.
  • 36. File-system Layout Zope/ doc/ Extensions/ import/ lib/ python/ Products/ var/ Data.fs ZServer/ The base folder Documentation Individual Python scripts For importing objects Libraries Zope’s extensions to Python Extensions to Zope Data folder The database file Web server
  • 37. Example Extension: Formulator HTML form construction framework. Form widgets ⇔ Formulator objects. Widgets can have validation rules. Automatic form construction. Or plugged into a ZPT template. Painless data validation. 37
  • 38. Supported Platforms Supported Operating Systems Windows Linux FreeBSD OpenBSD Solaris Mac OS X Supported Linux Distributions Red Hat Debian Mandrake SuSE Gentoo
  • 39. Resources Python: www.python.org Zope: www.zope.org The Indian Zope and Python User’s Group groups.yahoo.com/group/izpug