30. Creating reusable packages with eggsΒΆ
We already created an egg much earlier.
Now we are going to create a feature that is completely independent of our ploneconf site and can be reused in other packages.
To make the distinction clear, this is not a package from the namespace ploneconf
but from starzel
.
We are going to add a voting behavior.
For this we need:
- A behavior that stores it’s data in annotations
- A viewlet to present the votes
- A bit of javascript
- A bit of css
- Some helper views so that the Javascript code can communicate with Plone
We move to the src
directory and call a script called zopeskel
from our projects bin-directory.
$ mkdir src
$ cd src
$ ../bin/zopeskel
This returns a list of available templates we might use. We choose dexterity since it is pretty small but already has some of the right dependencies we need.
$ ../bin/zopeskel dexterity
We answer some questions:
- Enter project name:
starzel.votable_behavior
- Expert Mode? (What question mode would you like? (easy/expert/all)?) [‘easy’]:
easy
- Version (Version number for project) [‘1.0’]:
1.0.0
- Description (One-line description of the project) [‘Example Dexterity Product’]:
Voting Behavior
- Grok-Based? (True/False: Use grok conventions to simplify coding?) [True]:
False
- Use relations? (True/False: include support for relations?) [False]:
False
We have to modify the generated files slightly.
In setup.py
, we completely remove the variables setup_requires and paster_plugins. These are required for features that are rarely used and add a lot of code into the source directory that we don’t want. To the install_requires
list, we add an entry for plone.api
.
We just delete the file tests.py
. This is an outdated test system, we don’t want you to start from there.
The file profiles/default/types.xml
we just delete also. We won’t define new types.