2012/10/24

Plone Development Quick Tips

This document hints how to build a Plone development environment with minimum effort. Here we focus on development baby steps, not deployment. If possible, Ubuntu Linux 12.04 or later is preferred. Make sure you have installed the needed libraries. For newbies, it's much easier to install Plone with regular user account, not with root permission.

Useful Unified Installer Options

Linux Unified Installer provides a install.sh script, that makes things easy. Installation target directory and admin password can be specified.

$ tar xvpzf Plone-4.2.2-UnifiedInstaller
$ ./install.sh standalone \
  --target=/home/marr/plone422 --password=secret

Stand-Alone Zope Instance selected

Detailed installation log being written to
/home/marr/Downloads/Plone-4.2.2-UnifiedInstaller/install.log

Rootless install method chosen. Will install for use by system user marr

Installing Plone 4.2.2 at /home/marr/plone422

Skipping libjpeg build
Skipping readline build
Installing Python-2.7.3. This takes a while...
Installing distribute...
Python build looks OK.
Unpacking buildout cache to /home/marr/plone422/buildout-cache
Compiling .py files in egg cache
Copying Plone-docs
Your platform's xml2/xslt are missing or out-of-date. We'll need to build them.
Copying buildout skeleton
Fixing up bin/buildout
Building lxml with static libxml2/libxslt; this takes a while...
Building Zope/Plone; this takes a while...

#####################################################################
######################  Installation Complete  ######################

Plone successfully installed at /home/marr/plone422
See /home/marr/plone422/zinstance/README.html
for startup instructions

Use the account information below to log into the Zope Management Interface
The account has full 'Manager' privileges.

  Username: admin
  Password: secret

This account is created when the object database is initialized. If you change
the password later (which you should!), you'll need to use the new password.

- If you need help, ask the mailing lists or #plone on irc.freenode.net.
- The live support channel also exists at http://plone.org/chat
- You can read/post to the lists via http://plone.org/forums

- Submit feedback and report errors at http://dev.plone.org/plone
(For install problems, specify component "Installer (Unified)")

Preparing Package in the src Directory

In the above case, the directory ~/plone422/zinstance/src is used to store development source codes. Here is an example checking out the package source code from GitHub:

$ cd ~/plone422/zinstance/src
$ git clone https://github.com/collective/collective.masonry.git
Initialized empty Git repository in
/home/marr/plone422/zinstance/src/collective.masonry/.git/
remote: Counting objects: 314, done.
remote: Compressing objects: 100% (228/228), done.
remote: Total 314 (delta 147), reused 185 (delta 73)
Receiving objects: 100% (314/314), 52.36 KiB, done.
Resolving deltas: 100% (147/147), done.

Running buildout

buildout.cfg is the main file, which is extended by develop.cfg, so that development tools are included. After configuring the develop.cfg file, we run buildout to make it effective:

$ cd ~/plone422/zinstance
$ vi develop.cfg

[sources]
collective.masonry = fs collective.masonry

eggs +=
    collective.masonry

$ bin/buildout -c develop.cfg
mr.developer: Queued 'collective.masonry' for checkout.
mr.developer: Filesystem package 'collective.masonry' doesn't need a checkout.
Develop: '/home/marr/masonry/zinstance/src/collective.masonry'
...
Got collective.registry 1.0.
Got collective.js.imagesloaded 2.1.
Got collective.js.masonry 1.0.
Generated script '/home/marr/masonry/zinstance/bin/instance'.
Installing zopepy.
Generated interpreter '/home/marr/masonry/zinstance/bin/zopepy'.
Installing zopeskel.
Generated script '/home/marr/masonry/zinstance/bin/zopeskel'.
Generated script '/home/marr/masonry/zinstance/bin/paster'.
Installing omelette.
Updating backup.
Updating chown.
chown: Running echo Dummy references to force this to execute after referenced parts
echo /home/marr/masonry/zinstance/var/backups
chmod 600 .installed.cfg
find /home/marr/masonry/zinstance/var -type d -exec chmod 700 {} \;
chmod 744 /home/marr/masonry/zinstance/bin/*
Dummy references to force this to execute after referenced parts
/home/marr/masonry/zinstance/var/backups
Installing test.
Generated script '/home/marr/masonry/zinstance/bin/test'.
Updating repozo.
Updating unifiedinstaller.
*************** PICKED VERSIONS ****************
[versions]
collective.js.imagesloaded = 2.1
collective.js.masonry = 1.0
collective.registry = 1.0

*************** /PICKED VERSIONS ***************

Reading Buildout Messages

Don't panic when you see messages like these:

Thery are non-fatal errors.

Creating Dexterity Product Skeleton

For those who want Dexterity development environment for Plone 4.2.x, zopeskel.dexterity is your friend. After zopeskel.dexterity installed, you can run zopeskel to create dexterity package project:

$ cd src
$ ../bin/zopeskel dexterity

dexterity: A Dexterity-based product

This template expects a project name with 1 dot in it (a 'basic
namespace', like 'foo.bar').

Enter project name: myproj.dxcontent

In this case, add myproj.dxcontent in the develop.cfg file and run buildout -c develop.cfg to make it effective:

[sources]
# Examples: to check out plonetheme.sunburst from Plone's svn, use:
# plonetheme.sunburst = svn https://svn.plone.org/svn/plone/plonetheme.sunburst/trunk
#
# To use a python package that is being developed in your src subdirectory, use:
# myproduct.betterplone = fs myproduct.betterplone
myproj.dxcontent = fs myproj.dxcontent

Later, run paster addcontent to create dexterity_content or dexterity_behavior.

Here are the activated packages for Plone 4.2.2:

  • Dexterity Content Types 1.2.1
  • collective.z3cform.datetimewidget 1.2.1
  • plone.app.intid: install utility 1.0.1

No comments: