Benutzerspezifische Werkzeuge
Sie sind hier: Startseite Dokumentation HowTo:Plone 3 Theme Development Environment Setup
Artikelaktionen

HowTo:Plone 3 Theme Development Environment Setup

This stuff was in the air in the 'New Plone Themes' group when David Convent and Denis Mishunov instructed the sprinters in setting up the development environment to collaborate at the Naples Sprint from october 13th to 15th after the plone conference 2007 and turned into a How to by Armin Stroß-Radschinski. (Still some review is necessary)

Originally in progress on: http://www.openplans.org/projects/plone-conference-2007/themedevelopmentenvironmentsetup

You can use this also as an entry point if you want to remote sprint or later contribute to the new plone example themes.


Including some corrections and additions from selfexperience – Armin 2007-10-26 to 28th ;-) (and still some review by the community is welcome as usual - feel free to use the freedom to edit!)

Overview

  1. Step: Install the "Paste Script" (which installs the 'paster' command line tool)
  2. Create a buildout and the actual project files
  3. Run Zope & Create Plone Site inside Zope
  4. (optional) Create a new Plone3 theme in the plonetheme.xxx namespace and check it in into the Plone Collective

Appendix

  • System Requirements
  • Organisational predeceeding if you want to contribute your code
  • Updating to a new version of ZopeSkel
  • Browser Environment
  • Hurdles on different Operating Systems

  • Troubleshooting
  • Links

1. Step: Install the "Paster" Environment

Setting up easy_install and ZopeSkel to provide the Paster Script for easy setting up the necessary files for a project and installable Theme product egg.

If not having easy_install already installed in your python search for "ez_setup.py" in Google and get a current download URL or get it with:

wget http://peak.telecommunity.com/dist/ez_setup.py

install easy_install into your environment with:

sudo python ez_setup.py

Let easy_install download and install the ZopeSkel python module

sudo easy_install ZopeSkel

Now you can use the paster script to easy setup skeletons for different use-cases from existing templates. You can let paster list the available templates for the different assumptions by typing

paster create --list-templates

and get the output

Available templates:
  basic_namespace:    A project with a namespace package
  basic_package:      A basic setuptools-enabled package
  basic_zope:         A Zope project
  grokproject:        A grok project
  nested_namespace:   A project with two nested namespaces.
  paste_deploy:       A web application deployed through paste.deploy
  plone:              A Plone project
  plone2.5_buildout:  A buildout for Plone 2.5 projects
  plone2.5_theme:     A Theme for Plone 2.5
  plone2_theme:       A Theme Product for Plone 2.1 & Plone 2.5
  plone3_buildout:    A buildout for Plone 3 projects
  plone3_theme:       A Theme for Plone 3.0
  plone_app:          A Plone App project

2. Create the actual project files

Create the buildout for a individual Plone3 Zope development Instance

We create a Plone3 buildout named "NaplesThemes". We call it project directory in the later.

Type on the terminal prompt:

paster create -t plone3_buildout

and get (the bold stuff has to be typed by you!)

Selected and implied templates:
      ZopeSkel#plone3_buildout  A buildout for Plone 3 projects
   
    Enter project name: NaplesThemes
    Variables:
      egg:      NaplesThemes
      package:  naplesthemes
      project:  NaplesThemes
    Enter zope2_install (Path to Zope 2 installation; leave blank to fetch one) ['']: (optional)
    Enter plone_products_install (Path to directory containing Plone products; leave blank to fetch one) ['']: (optional)
    Enter zope_user (Zope root admin user) ['admin']: (optional)
    Enter zope_password (Zope root admin password) ['']: *****
    Enter http_port (HTTP port) [8080]: (optional)
    Enter debug_mode (Should debug mode be "on" or "off"?) ['off']: on
    Enter verbose_security (Should verbose security be "on" or "off"?) ['off']: on
    Creating template plone3_buildout
    Creating directory ./NaplesThemes
      Copying README.txt to ./NaplesThemes/README.txt
      Copying bootstrap.py to ./NaplesThemes/bootstrap.py
      Copying buildout.cfg_tmpl to ./NaplesThemes/buildout.cfg
      Recursing into products
        Creating ./NaplesThemes/products/
        Copying README.txt to ./NaplesThemes/products/README.txt
      Recursing into src
        Creating ./NaplesThemes/src/
        Copying README.txt to ./NaplesThemes/src/README.txt
      Recursing into var
        Creating ./NaplesThemes/var/
        Copying README.txt to ./NaplesThemes/var/README.txt
    -----------------------------------------------------------
    Generation finished
    You probably want to run python bootstrap.py and then edit
    buildout.cfg before running bin/buildout -v
   
    See README.txt for details
    -----------------------------------------------------------

To initialize the environment run:

python bootstrap.py

Checkout from SVN

(If you want to create your own new Plone Theme Product goto to step 4. Create a new Plone3 theme in the plonetheme.xxx namespace and check it in into the Plone Collective and proceed with Edit buildout.cfg)

Now we download the products we are working on from the development development repository on plone.org.

Go into the src directory of your project directory

cd NaplesThemes/src

Check out the existing product skeletton fron svn:

svn co http://svn.plone.org/svn/collective/plonetheme.pizza/trunk plonetheme.pizza

or

svn co http://svn.plone.org/svn/collective/plonetheme.napoli/trunk plonetheme.napoli

Go back to the project directory

cd ..

Edit buildout.cfg

Edit the buildout.cfg file to let the Instance recognize the new products in the "new way"

use

vi buildout.cfg

or your favorite editor and add the following lines inside at three locations of the file that are marked bold (If you are working only on one theme omit the lines for one of them)

[buildout]
parts =
    plone
    zope2
    productdistros
    instance
    zopepy

# Add additional egg download sources here. dist.plone.org contains archives
# of Plone packages.
find-links =
    http://dist.plone.org
    http://download.zope.org/ppix/
    http://download.zope.org/distribution/
    http://effbot.org/downloads

# Add additional eggs here
# elementtree is required by Plone
eggs =
    elementtree
    plonetheme.napoli
    plonetheme.pizza

   
# Reference any eggs you are developing here, one per line
# e.g.: develop = src/my.package
develop =
    src/plonetheme.napoli
    src/plonetheme.pizza

[plone]
recipe = plone.recipe.plone

[zope2]
recipe = plone.recipe.zope2install
url = ${plone:zope2-url}

# Use this section to download additional old-style products.
# List any number of URLs for product tarballs under URLs (separate
# with whitespace, or break over several lines, with subsequent lines
# indented). If any archives contain several products inside a top-leve
# directory, list the archive file name (i.e. the last part of the URL,
# normally with a .tar.gz suffix or similar) under 'nested-packages'.
# If any archives extract to a product directory with a version suffix, list
# the archive name under 'version-suffix-packages'.
[productdistros]
recipe = plone.recipe.distros
urls =
nested-packages =
version-suffix-packages =

[instance]
recipe = plone.recipe.zope2instance
zope2-location = ${zope2:location}
user = admin:*****
http-address = 8080
debug-mode = on
verbose-security = on

# If you want Zope to know about any additional eggs, list them here.
# This should include any development eggs you listed in develop-eggs above,
# e.g. eggs = ${buildout:eggs} ${plone:eggs} my.package
eggs =
    ${buildout:eggs}
    ${plone:eggs}

# If you want to register ZCML slugs for any packages, list them here.
# e.g. zcml = my.package my.other.package
zcml =
    plonetheme.napoli
    plonetheme.pizza


products =
    ${buildout:directory}/products
    ${productdistros:location}
    ${plone:products}

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
extra-paths = ${zope2:location}/lib/python
scripts = zopepy

finally run (the '-v' option is for having a 'verbose' mode):

./bin/buildout -v

Now you can start Zope on the prompt with

./bin/instance fg

3. Run Zope & Create Plone Site inside Zope

  • Choose "Plone Site" from the "Add" menu and add titel, id & description as described
  • Open the site in a second tab or browser
    http://localhost:8080/yourid/
Go on with Theme Development in the file system with Firefox, Firebug and Friends

4. Create a new Plone3 theme of your own in the plonetheme.xxx namespace and check it in into the Plone Collective

Preconditions

  • a Plone3_buildout already created locally on your system

Create the new Plone3 theme product with paster

Note: This part was added but NOT seriously tested until 28th of october 2007 and contained some mistakes

cd into the src subdirectory of your project directory.
cd ../../NaplesThemes/src
To run the paster script, go to terminal and type at the prompt:
paster create -t plone3_theme
and get (the bold stuff has to be typed by you! Italic text is comment and not to be typed))
Selected and implied templates:
ZopeSkel#basic_namespace A project with a namespace package
ZopeSkel#plone A Plone project
ZopeSkel#plone3_theme A Theme for Plone 3.0

Enter project name: plonetheme.mytheme
Variables:
egg: plonetheme.mytheme
package: plonethememytheme
project: plonetheme.mytheme
Enter namespace_package (Namespace package (like plonetheme)) ['plonetheme']: plonetheme
Enter package (The package contained namespace package (like example)) ['example']: mytheme
Enter skinname (The skin selection to be added to 'portal_skins' (like 'My Theme')) ['']: My Theme
Enter skinbase (Name of the skin selection from which the new one will be copied) ['Plone Default']: #change only if nec.
Enter include_doc (Include in-line documentation in generated code?) [False]: True # important for newbees, gives in place advice!
# If you are confused: the printed line above changed with the new version of paster
# The old text was: (Include in-line documentation in 'config.py'?)
# The file config.py no longer exists!

Enter zope2product (Are you creating a Zope 2 Product?) [True]: # Plone3 runs on Zope 2 only!
Enter version (Version) ['0.1']: # use the versioning schema suggested by the Plone community!
Enter description (One-line description of the package) ['An installable theme for Plone 3.0']: An installable theme for Plone 3.0
Enter long_description (Multi-line description (in reST)) ['']: This is my Plone 3 theme
Enter author (Author name) ['Plone Collective']: My Name
Enter author_email (Author email) ['product-developers@lists.plone.org']: myaddress@mycom.com
Enter keywords (Space-separated keywords/tags) ['web zope plone theme']: web zope plone theme mytheme # use proper tagging if contributing!
Enter url (URL of homepage) ['http://svn.plone.org/svn/collective/']: http://svn.plone.org/svn/collective/plonetheme.mytheme # use a maillist if applicable!
Enter license_name (License name) ['GPL']: # create free software!
Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]: False # important because zipped eggs do not work in zope!
Creating template basic_namespace
...

After the the paster script stops execution without any errors a new folder plonetheme.mytheme shows up in the src directory. Enter the name of the theme product in the buildout.cfg file as described in [2.] and run ./bin/buildout -v again from the project directory.

Share the code

If you want to contribute to the community read the pages on plone.org on contribution code and get Plone SVN-Collective write access to share the theme!

Appendix

System requirements

installed Python 2.4.4 (not 2.5 for now!) with easy_install
installed gcc compiler
installed svn client

Organisational preconditions if you want to contribute your code

Browser Environment

using latest Firefox 2.x with the following installed plug-ins suggested
optional
If you want to look for latest versions search on https://addons.mozilla.org/firefox/search

Updating to a new version of ZopeSkel

Go to the terminal and type:
easy_install -u ZopeSkel

Benefits at the time of 14th october 14:44: Some typos removed, improvements on Windows. (MacOSX and Linux might not need this today)

It is useful to be up to date!

Hurdles on different Operating Systems

Predeceeding installs and troubleshooting in mind if not on Linux and new to development
  • Linux
    • consult the documentation of your distribution how to install Python, gcc and svn
  • MacOSX
    • we suggest to use a Python 2.4.4 compiled from sources or installed with MacPorts (avoid using the system Python or the binary distributions)
    • you need the Development Tools installed to get a working gcc compiler!
      (came with your Install disks or can be downloaded from the developer secton of the Apple website)
    • install svn from sources if you know what you are doing or use a binary distribution or MacPorts
    • install wget or use curl instead (search http://www.versiontracker.com/ for "wget")
  • Windows
    • Install Python 2.4.4 from the binaries
    • you need to install a cygwin environment in most cases to get a free gcc compiler and install from sources
    • install svn from sources if you know what you are doing or use a binary distribution
Every time you see the "python" command use the "PathtoYourPython2.4.4/bin/python" instead, if you have not setup this as a default.

Troubleshooting

  • ERROR : When starting the instance in foreground mode, the error is:
    Traceback (most recent call last):
    File

    "/tmp/plone/pizza/parts/zope2/lib/python/Zope2/Startup/run.py",line 56, in ?
    run()
    File
    "/tmp/plone/pizza/parts/zope2/lib/python/Zope2/Startup/run.py",line 21, in run
    starter.prepare()
    File
    "/tmp/plone/pizza/parts/zope2/lib/python/Zope2/Startup/__init__.py",line 98, in prepare
    self.dropPrivileges()
    File
    "/tmp/plone/pizza/parts/zope2/lib/python/Zope2/Startup/__init__.py",line 234, in dropPrivileges
    return dropPrivileges(self.cfg)
    File
    "/tmp/plone/pizza/parts/zope2/lib/python/Zope2/Startup/__init__.py",line 403, in dropPrivileges
    raise
    ZConfig.ConfigurationError(msg)
    ZConfig.ConfigurationError: A user was not specified to setuid to; fix this to start as root
    (change the effective-user directive in zope.conf)

    SOLUTION : don't build the buildout as a system administrator, build it with normal user rights...
    (fix provided by Jarno de Wit)
  • ERROR : I tried to run
    ./bin/buildout
    in the project-directory from the command line, but there is no /bin/buildout in my project directory!

    SOLUTION :  Probably you forgot to run the following line on the command line.
    python bootstrap.py
    Afterwards /bin/buildout should be there!
    (fix provided by David Convent)

Further documentation