Example of two clients and a zeo server with a pip installation of Plone 6

Is there an example how to configure two clients accessing a zeo server with a pip installation of Plone 6?
Can this be done with cookiecutter-zope-instance?

In other words, how to get a similar configuration in a pip installation of Plone 6 as if we do install it like the following?

sudo ./install.sh \
    zeocluster \
    --with-python=/usr/bin/python3 \
    --password=admin \
    --target=/home/Plone-6.0-latest\
    --clients=2 \
    --instance=zeocluster \
    --daemon-user=plone_daemon \
    --owner=buildout_user \
    --group=plone_group \
    ;

Example How To Create a ZEO Cluster with Plone 6 and pip

Example to install Plone with

  • two Plone-clients
  • reading from and storing data in a ZEO-server
  • with files and images stored a shared blobstorage.

Prepare Environment

mkdir -p zeoexample/blobstorage
cd zeoexample
python3.9 -m venv venv
source venv/bin/activate
python -m pip install -U pip

Install the packages needed

python -m pip install Plone zeo zope.mkzeoinstance "cookiecutter==2.1.1" -c https://dist.plone.org/release/6.0.0b1/constraints.txt

Configure and start a ZEO Server

Run mkzeoinstance zeo localhost:8100.
This creates a folder zeo with all in place to start the ZEO-server on the given host and port.

Test-start the server zeo/bin/runzeo to look for error messages (and then stop it with Ctrl-C).

Start the server as a daemon with zeo/bin/zeoctl start.

Later you can stop the server with zeo/bin/zeoctl stop.

Configure Plone and ZEO

Create two configurations for cookiecutter-zope-instance.
The only difference is target and the wsgi_listen port.

File instance01.yml:

default_context:
    wsgi_listen: 'localhost:8081'
    target: 'instance01'

    initial_user_name: 'admin'
    initial_user_password: 'admin'

    db_storage: zeo
    db_zeo_server: 'localhost:8100'
    db_blobs_location: 'FULL_PATH_TO/blobstorage/'

File instance02.yml:

default_context:
    wsgi_listen: 'localhost:8082'
    target: 'instance02'

    [insert same as in instance01.yml]

Run cookiecutter to generate the more complex Zope (and so Plone) configuration.

cookiecutter -f --no-input --config-file instance01.yml https://github.com/plone/cookiecutter-zope-instance
cookiecutter -f --no-input --config-file instance02.yml https://github.com/plone/cookiecutter-zope-instance

Running Plone

Start a Plone client instance with runwsgi instance01/etc/zope.ini and the second one with runwsgi instance02/etc/zope.ini.

4 Likes

@jensens: Thank you very much! zope.mkzeoinstance was the missing link.

Is this a common use case? If so, this would be a nice addition to the docs. I'm not sure where it should go, perhaps here?

1 Like

Indeed, at least the bit of installing a zeo-server (zope.mkzeoinstance) together with the cookiecutter configuration for using the zeo-server in a Plone client is missing.

https://6.dev-docs.plone.org/install/install-from-packages.html still miss this precious infos. Are they uptodate? I'm testing them using 6.0b3 and they works but I'm guessing on how to add addons then...

still miss this precious infos

Pull requests are welcome as usual :wink: (copy paste from this thread would be a first important step).

but I'm guessing on how to add addons then

Here is the basic information: Plone 6 Documentation — Plone Documentation v6.0
If something is not clearly written, please tell us! Then we can improve the docs.

${PLONE_HOME}/bin/mrbob -O ${PLONE_HOME}/src/myaddon.name bobtemplates.plone:addon
...
${PLONE_HOME}/bin/pip install -e ${PLONE_HOME}/src/myaddon.name

This gist might help: (install_plone.md · GitHub)

This worked!

@jensens Doing:

pip install Plone zeo zope.mkzeoinstance "cookiecutter==2.1.1" -c https://dist.plone.org/release/6.0.0b1/constraints.txt

got stuck after downloading all the eggs (python 100% with top, no text output after several minutes), while installing Plone, zeo and zope.mkzeoinstance separately worked.

Installing from pip, so I don't have any instance.yml or cookiecutter-plone-starter in place. I did it with pip install addon and worked but what about versions or constrainst?

Maybe it is better to use mxdev and cookiecutter-plone-starter?

Sounds like an outdated pip version. At least I had the problem once. Did you try to update: pip install -U pip?

1 Like

That could be. When I tried the second way, I upgraded pip as the gist suggested. Thanks!

A question: is it possible to install just the classic part of Plone 6 and skip frontend/Volto using the cookiecutter plone starter? Reading the makefile, I think it is make install-backend.

My goal is to create a prod environment for a Plone ClassicUI site.

Yes, either this way or you can cd in the backend folder and then run there the make commands directly.

/cookiecutter-plone-starter/{{ cookiecutter.project_slug }}/backend# make build-dev
+ which python3
++ tput setaf 2
++ tput sgr0
+ echo '==> Create instance configuration'
==> Create instance configuration
+ bin/cookiecutter -f --no-input --config-file instance.yaml gh:plone/cookiecutter-zope-instance
Unable to render variable 'load_zcml'
Error message: 'collections.OrderedDict object' has no attribute 'python_package_name'
Context: {

The problem is that I cannot run make config (same error as above) neither cookiecutter . because it tries to install volto npm packages and the docker instance, while I would like just to install Plone 6 Classic UI locally.

So, is it possible to use https://github.com/collective/cookiecutter-plone-starter to install Plone or the best way is to use a minimal mx.ini as you showed at the PloneConf 2022?

Yes! Just clone it, edit the post hook and comment out the prepare_frontend part, then go to the {{ }} template dir -> backend and in the Makefile comment out the $(FORMAT) part (it is a docker command).

Then run make install-backend and :coffee: wait.

Great!

1 Like

Notes:

  • don't use a pyenv virtualenv because zcml path will conflict when creating the zope instance. The cookiecutter template already create a virtualenv, so just use pyenv to set the python interpreter
  • The cookiecutter template will create a zope instance with wsgi binding to localhost 8080. If you're using a remote server, just change the listen= line in zope.ini
  • The cookiecutter template create a volto site
  • If you create a plone classic ui site, in the addons control panel there's collective.MockMailHost available. I think this is a leftover, it also says that if installed, it cannot be uninstalled
  • Nice that cookiecutter create an addon with the name of the site, the code is in src and seems to have all what you need preconfigured (maybe generated with plonecli?):
behaviors
browser
configure.zcml
content
dependencies.zcml
indexers
__init__.py
interfaces.py
locales
permissions.zcml
profiles
profiles.zcml
__pycache__
serializers
services
setuphandlers
subscribers
testing.py
tests
upgrades
vocabularies

Buildout is quite mature and works very well but when coredev buildout will adopt mxdev/cookiecutter the situation will improve I think.

I want to share the load_zcml between the muti clients so when I scale up clients (instance.ymal) I do not need to duplicate the packages like so, any thoughts?

    load_zcml:
        package_includes: [
            'eea.facetednavigation',
            'transmogrify.dexterity',
            'plone.app.jquerytools',
            'collective.solr',
            'collective.volto.cookieconsent'
        ]
1 Like