Getting started¶
How to get started with Plone development.
- Introduction
- Installing Plone
- Non-programming approaches for customizing Plone
- Enabling debug mode
- Plone add-ons as Python packages
- Finding and installing add-on packages
- Creating your first add-on
- Plone development workflow
- Plone add-on features
- Development mode restarts
- Through-the-web customizations
- Hello World Tutorial
- Plone resources
- Zope resources
- Python resources
- Debug mode explained
Introduction¶
Plone is developed in the Python programming language. You should master Python basics before you can efficiently customize Plone. If you are very new to Python, Plone or software development, it is suggested that you read the Professional Plone 4 Development book before you attempt to develop your own solutions.
Plone runs on the top of the Zope 2 application server, meaning that one Zope 2 server process can contain and host several Plone sites. Plone also uses Zope 3 components. Zope 3 is not an upgrade for Zope 2, but a separate project.
Internally, Plone uses the objected-oriented ZODB database and the development mindset greatly differs from that of SQL based systems. SQL backends can still be integrated with Plone, like for any other Python application, but this is a more advanced topic.
Installing Plone¶
It is recommended that you do Plone development on Linux or OS X. Development on Windows is possible, but you need to have much more experience dealing with Python and Windows related problems, so starting on Windows is not so easy.
See installation instructions for how to create a Plone installation suitable for development.
Non-programming approaches for customizing Plone¶
If you lack programming skill or resources, you can still get some things done in Plone:
- Plomino is a a powerful and flexible web-based application builder for Plone
- PloneFormGen allows you to build forms in a web browser
- Plone 4+ comes with through-the-web Dexterity content type editor
However, for heavy customization, Python, JavaScript, TAL page templates and CSS programming is needed.
Enabling debug mode¶
By default, Plone runs in a production mode where changed files in the file system are not reflected in the served HTML. When you start developing Plone you need to first put it into a debug mode.
Plone add-ons as Python packages¶
Plone sites can be customized by installing Plone add-ons, which add or customize functionality. You can install existing add-ons that others have developed or you can develop and install your own add-ons. Add-ons are developed and distributed as Python packages. Many open-source Python packages, including Plone add-ons, are available from PyPI (the Python Package index).
Plone uses a tool called
Buildout
to manage the set of Python packages that are part of your
Plone installation. Using Buildout involves using the
buildout.cfg
configuration file and the
bin/buildout
command.
Note
In prior versions of Plone and Zope, add-ons were
referred to as "products" and they were
installed by copying them into a special folder called
products
. This method is now deprecated in favor of using
standard Python packages, managed by Buildout.
Finding and installing add-on packages¶
Plone add-ons can be found at the plone.org Products page or at the PyPI (the Python Package index).
See the Installing add-on packages using buildout section for more details.
Creating your first add-on¶
Since Python egg package structure is little bit complex,
to get started with your first add-on you can create a
code skeleton (scaffold) for it using
Plone
ZopeSkel
code
templates
.
- ZopeSkel generates a basic Python egg package with some Plone files in-place.
-
This package is registered to buildout as a development
egg in the
buildout.cfg
file. -
Buildout is rerun which regenerates your
bin/instance
script with the new set of Python eggs. - You start your Plone instance in debug mode.
-
You install your add-on through
Add/remove add-ons
Note
There are different scaffolds for different kind of
add-ons. The most typically used are
plone3_theme
,
archetype
(create Archetypes content),
dexterity
(create Dexterity content) and
plone
(barebone Plone add-on).
Please read how to use
ZopeSkel
to
bootstrap
your
first
add-on
.
Plone development workflow¶
You never edit Plone files directly. Everything under
parts
and
eggs
folders in your Plone installation is downloaded from the
Internet and dynamically generated by Buildout, based on
buildout.cfg
. Buildout is free to override these files on any update.
You need to have your own add-on in the
src/
folder as created above. There you overlay changes to the
existing Plone core through extension mechanisms provided
by Plone:
Plone development always happens on your local computer or the development server. The changes are moved to production through version control system like Git or Subversion.
The best practice is that you install Plone on your local computer for development.
Plone add-on features¶
Plone add-ons usually:
- Create custom content types or extend existing ones for your specialized need. Plone has two subsystems for content types: Dexterity and Archetypes (old).
- Add new views for your site and its content.
-
Create Python-processed
forms
on your site. - Theme your site
- etc.
A lot of Plone functionality is built on Zope 3 development patterns like adapters and interfaces. These design patterns take some time to learn, but they are crucial in complex component based software like Plone.
Development mode restarts¶
Plone must be started in the development mode using
bin/instance
fg
command. Then
- Javascript files are in debug mode and automatically loaded when you hit refresh
- CSS files are in debug mode and automatically loaded when you hit refresh
- TAL page templates (.pt files) are automatically reloaded on every request
- GenericSetup XML files are reloaded
Please note that Plone development mode does not reload
.py
or
.zcml
files by default. This is possible, however. Use the
sauna.reload
package to make Plone reload your Python code
automatically when it is changed.
Through-the-web customizations¶
Some aspects of Plone can be changed through the Zope Management Interface (ZMI). Documentation here does not focus on extending functionality through the ZMI because this method is severely limited and usually can take you only half way there.
Hello World Tutorial¶
We have a tutorial introducing the basics of Plone development.
The tutorial covers a basic form, a custom content-type, and a dynamic view. It also has detailed sections on building a development environment, installing Plone, and creating an add-on package for your development code.
Plone resources¶
- Plone Trac contains bug reports, Plone source code and commits. Useful when you encounter a new exception or you are looking for a reference on how to use the API.
- Plone source code in version control system.
- Plone API (in development).
Zope resources¶
-
Zope 2 book. This describes old Zope 2 technologies. The book is mostly good for explaining some old things, but '''do not''' use it as a reference for building new things.
The chapters on Zope Page Templates however are still the best reference on the topic.