• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Python eggs, zc.buildout, zopeproject and zope3
 

Python eggs, zc.buildout, zopeproject and zope3

on

  • 23,391 views

A simple introduction to getting a start with Zope3 using eggs, zc.buildout and zopeproject

A simple introduction to getting a start with Zope3 using eggs, zc.buildout and zopeproject

Statistics

Views

Total Views
23,391
Views on SlideShare
7,612
Embed Views
15,779

Actions

Likes
6
Downloads
65
Comments
0

15 Embeds 15,779

http://www.buildout.org 15732
http://www.slideshare.net 10
http://translate.googleusercontent.com 9
http://docs.zope.org 6
http://www.linkedin.com 5
http://buildout.readthedocs.org 4
https://buildout-docs.readthedocs.org 3
http://svn.zope.org 2
http://nzpug.org 2
http://webcache.googleusercontent.com 1
http://web.archive.org 1
http://131.253.14.66 1
http://131.253.14.250 1
http://192.168.10.10 1
http://www.techgig.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Python eggs, zc.buildout, zopeproject and zope3 Python eggs, zc.buildout, zopeproject and zope3 Presentation Transcript

    • Eggs, zc.buildout and Zope3 Getting started with eggs, zc.buildout and Zope3 Darryl Cousins info@tfws.org.nz Tree Fern Web Services New Zealand Python User Group meeting, February 2008 Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 1 / 25
    • Eggs A Python Module • A block of code which may imported by some other code. Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 2 / 25
    • Eggs A Python Module: hello.py def helloworld(): print uquot;Hello Worldquot; Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 3 / 25
    • Eggs A Python Module: hello.py def helloworld(): print uquot;Hello Worldquot; We can import the method from the module: from hello import helloworld Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 3 / 25
    • Eggs A Python Package: hello A package is a module that contains other modules: hello/ __init__.py hello.py Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 4 / 25
    • Eggs A Python Package: hello A package is a module that contains other modules: hello/ __init__.py hello.py Now we must import the method from the module within the module. from hello.hello import helloworld Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 4 / 25
    • Eggs Distutils Distutils was written so we have a unified way to install python modules. python setup.py install Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 5 / 25
    • Eggs Distutils - creating a distribution To distribute the hello module we need have it in a directory with a setup.py file. workingdir/ setup.py hello/ __init__.py hello.py Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 6 / 25
    • Eggs Distutils - creating a distribution To distribute the hello module we need have it in a directory with a setup.py file. workingdir/ setup.py hello/ __init__.py hello.py The setup.py file needs at the least the following. from distutils.core import setup setup(name=quot;helloquot;, ) Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 6 / 25
    • Eggs Distutils - creating a distribution, continued Now we can create a distribution tarball with disutils. python setup.py sdist Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 7 / 25
    • Eggs Distutils - creating a distribution, continued Now we can create a distribution tarball with disutils. python setup.py sdist Our directory now looks like this workingdir/ setup.py hello/ __init__.py hello.py dist/ hello-1.0.tar.gz Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 7 / 25
    • Eggs Distutils - creating a distribution, continued Now we can create a distribution tarball with disutils. python setup.py sdist Our directory now looks like this workingdir/ setup.py hello/ __init__.py hello.py dist/ hello-1.0.tar.gz If we unpack the source distribution it looks like this: hello-1.0/ PKG-INFO setup.py hello/ __init__.py hello.py Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 7 / 25
    • Eggs Setuptools • Setuptools is built on top of distutils • uses the setup.py • uses eggs for distribution • allows us to save our modules as eggs to pypi Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 8 / 25
    • Eggs Setuptools • Setuptools is built on top of distutils • uses the setup.py • uses eggs for distribution • allows us to save our modules as eggs to pypi Installing setuptools wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 8 / 25
    • Eggs Eggs To create an egg change the import line in setup.py from setuptools import setup setup(name=quot;helloquot;, version=quot;1.0quot;, ) Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 9 / 25
    • Eggs Eggs To create an egg change the import line in setup.py from setuptools import setup setup(name=quot;helloquot;, version=quot;1.0quot;, ) We can call that with: python setup.py bdist_egg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 9 / 25
    • Eggs Eggs To create an egg change the import line in setup.py from setuptools import setup setup(name=quot;helloquot;, version=quot;1.0quot;, ) We can call that with: python setup.py bdist_egg Which creates a binary egg in our dist directory dist/ hello-1.0-py2.4.egg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 9 / 25
    • Eggs Pypi If we want that egg available on pypi and we have an account we can do that with a single command. python setup.py sdist upload Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 10 / 25
    • Eggs Pypi If we want that egg available on pypi and we have an account we can do that with a single command. python setup.py sdist upload Which all the world can use easy_install hello Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 10 / 25
    • zc.buildout zc.buildout - what is it? • Buildout is a system of configuring repeatable steps for assembling complicated systems (applications) from multiple parts. Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 11 / 25
    • zc.buildout zc.buildout - what is it? • Buildout is a system of configuring repeatable steps for assembling complicated systems (applications) from multiple parts. • A real world example of my own includes: • apache • postgresql • ramdb • zope3 • sqlalchemy • pyxml • egenix-mx-base • psycopg2 Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 11 / 25
    • zc.buildout Example buildout.cfg [buildout] develop = . parts = py [py] recipe = zc.recipe.egg interpreter = py eggs = hello Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 12 / 25
    • zc.buildout So - how to get started with Zope3 • Download tarball. Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 13 / 25
    • zc.buildout So - how to get started with Zope3 • Download tarball. Wrong! Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 13 / 25
    • zc.buildout So - how to get started with Zope3 • Download tarball. Wrong! • Use zopeproject Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 13 / 25
    • zc.buildout Virtual Environment virtualenv nzpug Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 14 / 25
    • zc.buildout Virtual Environment virtualenv nzpug cd nzpug ./bin/easy_install zopeproject Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 14 / 25
    • zc.buildout Virtual Environment virtualenv nzpug cd nzpug ./bin/easy_install zopeproject bin/zopeproject nzpug Enter user (Name of an initial administrator): darryl Enter passwd (Password for .. ): secret Enter eggs_dir (Location ..) [’/opt/buildout/eggs’]: ** Creating directory ./nzpug Downloading zc.buildout.. Invoking zc.buildout.. Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 14 / 25
    • zc.buildout .buildout/default.cfg [buildout] eggs-directory=/opt/buildout/eggs develop-eggs-directory=/opt/buildout/develop-eggs download-cache=/opt/buildout/cache Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 15 / 25
    • zc.buildout nzpug/buildout.cfg [buildout] develop = . parts = app test find-links = http://download.zope.org/distribution/ newest = false # eggs will be installed in the default buildout location # (see ~/.buildout/default.cfg) Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 16 / 25
    • zc.buildout nzpug/buildout.cfg [buildout] develop = . parts = app test find-links = http://download.zope.org/distribution/ newest = false # eggs will be installed in the default buildout location # (see ~/.buildout/default.cfg) extends = http://download.zope.org/zope3.4/versions-3.4.0.cfg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 16 / 25
    • zc.buildout nzpug/buildout.cfg (continued) [app] recipe = zc.recipe.egg eggs = nzpug zope.app.apidoc zope.app.securitypolicy z3c.evalexception>=2.0 Paste PasteScript PasteDeploy interpreter = python Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 17 / 25
    • zc.buildout nzpug/buildout.cfg (continued) [app] recipe = zc.recipe.egg eggs = nzpug zope.app.apidoc zope.app.securitypolicy z3c.evalexception>=2.0 Paste PasteScript PasteDeploy interpreter = python [test] recipe = zc.recipe.testrunner eggs = nzpug defaults = [’--tests-pattern’, ’^f?tests$’, ’-v’] Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 17 / 25
    • zc.buildout Directory contents bin/ log/ parts/ src/ var/ apidoc.zcml buildout.cfg debug.ini deploy.ini setup.py site.zcml zdaemon.conf zope.conf Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 18 / 25
    • zc.buildout What’s in the bin directory? buildout nzpug-ctl nzpug-debug paster python static-apidoc test Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 19 / 25
    • zc.buildout nzpug/deploy.ini [app:main] use = egg:nzpug [server:main] use = egg:Paste#http host = 127.0.0.1 port = 8080 Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 20 / 25
    • zc.buildout What’s in the src/nzpug directory? __init__.py configure.zcml ftesting.zcml startup.py testing.py Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 21 / 25
    • zc.buildout A HelloWorld - step 1: The template hello.pt <html i18n:domain=quot;nzpugquot;> <head> <title i18n:translate=quot;quot;>Hello World</title> </head> <body i18n:translate=quot;quot;> Hello World </body> </html> Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 22 / 25
    • zc.buildout A HelloWorld - step 2: The registration configure.zcml <configure xmlns=quot;http://namespaces.zope.org/zopequot; xmlns:browser=quot;http://namespaces.zope.org/browserquot; i18n_domain=quot;nzpugquot;> <page for=quot;*quot; name=quot;helloquot; permission=quot;zope.Publicquot; template=quot;hello.ptquot; /> </configure> Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 23 / 25
    • zc.buildout A HelloWorld - step 2: The registration configure.zcml <configure xmlns=quot;http://namespaces.zope.org/zopequot; xmlns:browser=quot;http://namespaces.zope.org/browserquot; i18n_domain=quot;nzpugquot;> <page for=quot;*quot; name=quot;helloquot; permission=quot;zope.Publicquot; template=quot;hello.ptquot; /> </configure> ./bin/nzpug-ctl fg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 23 / 25
    • zc.buildout A HelloWorld - step 2: The registration configure.zcml <configure xmlns=quot;http://namespaces.zope.org/zopequot; xmlns:browser=quot;http://namespaces.zope.org/browserquot; i18n_domain=quot;nzpugquot;> <page for=quot;*quot; name=quot;helloquot; permission=quot;zope.Publicquot; template=quot;hello.ptquot; /> </configure> ./bin/nzpug-ctl fg http://localhost:8080/hello Hello World Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 23 / 25
    • zc.buildout Hello who? hello.pt <html i18n:domain=quot;nzpugquot;> <head> <title i18n:translate=quot;quot;>Hello World</title> </head> <body i18n:translate=quot;quot;> Hello <span tal:replace=quot;view/request/who|defaultquot; >World</span> </body> </html> Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 24 / 25
    • zc.buildout Hello who? hello.pt <html i18n:domain=quot;nzpugquot;> <head> <title i18n:translate=quot;quot;>Hello World</title> </head> <body i18n:translate=quot;quot;> Hello <span tal:replace=quot;view/request/who|defaultquot; >World</span> </body> </html> ./bin/nzpug-ctl fg http://localhost:8080/hello?who=Darryl Hello Darryl Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 24 / 25
    • zc.buildout Create a distribution of our app python setup.py bdist_egg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 25 / 25
    • zc.buildout Create a distribution of our app python setup.py bdist_egg ls dist nzpug-0.1-py2.4.egg Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 25 / 25