SlideShare a Scribd company logo
1 of 45
Download to read offline
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

More Related Content

Recently uploaded

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Recently uploaded (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Python eggs, zc.buildout, zopeproject and zope3

  • 1. 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
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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
  • 17. 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
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. 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
  • 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
  • 26. zc.buildout Virtual Environment virtualenv nzpug Darryl Cousins info@tfws.org.nz (Tree Fern Web Services) Zope3 NZPUG February 2008 14 / 25
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. 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
  • 31. 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
  • 32. 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
  • 33. 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
  • 34. 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
  • 35. 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
  • 36. 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
  • 37. 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
  • 38. 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
  • 39. 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
  • 40. 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
  • 41. 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
  • 42. 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
  • 43. 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
  • 44. 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
  • 45. 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