Skip to content

make remove-data breaks make start and make create-site & lacks clarity on its purpose #286

@jnptk

Description

@jnptk

After running

make remove-data

the following commands fail with the following errors:

make start:

$ make start
🐎 This Python (/Users/username/path/to/addon/.venv/bin/python3) uses horse-with-no-namespace to make pkg_resources namespace packages compatible with PEP 420 namespace packages.
Traceback (most recent call last):
  File "/Users/username/path/to/addon/.venv/bin/runwsgi", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/serve.py", line 251, in main
    return command.run()
           ~~~~~~~~~~~^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/serve.py", line 180, in run
    setup_logging(log_fn, global_conf=vars)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/serve.py", line 78, in setup_logging
    return fileConfig(
        config_file, full_global_conf, disable_existing_loggers=False)
  File "/Users/username/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/logging/config.py", line 90, in fileConfig
    handlers = _install_handlers(cp, formatters)
  File "/Users/username/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/logging/config.py", line 161, in _install_handlers
    h = klass(*args, **kwargs)
  File "/Users/username/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/logging/__init__.py", line 1218, in __init__
    StreamHandler.__init__(self, self._open())
                                 ~~~~~~~~~~^^
  File "/Users/username/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/logging/__init__.py", line 1247, in _open
    return open_func(self.baseFilename, self.mode,
                     encoding=self.encoding, errors=self.errors)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/username/path/to/addon/instance/var/log/instance-access.log'
make: *** [start] Error 1

make create-site:

$ make create-site
🐎 This Python (/Users/username/path/to/addon/.venv/bin/python3) uses horse-with-no-namespace to make pkg_resources namespace packages compatible with PEP 420 namespace packages.
Traceback (most recent call last):
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/info.py", line 54, in convert
    return datatype(self.value)
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/datatypes.py", line 340, in existing_dirpath
    raise ValueError('The directory named as part of the path %s '
                     'does not exist.' % v)
ValueError: The directory named as part of the path /Users/username/path/to/addon/instance/var/filestorage/Data.fs does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/username/path/to/addon/.venv/bin/zconsole", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/utilities/zconsole.py", line 50, in main
    runscript(namespace.zopeconf, *namespace.scriptargs)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/utilities/zconsole.py", line 13, in runscript
    make_wsgi_app({}, zopeconf)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/run.py", line 51, in make_wsgi_app
    opts = ZopeWSGIOptions(configfile=zope_conf)()
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/options.py", line 84, in __call__
    self.load_configfile()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/Zope2/Startup/options.py", line 79, in load_configfile
    self.configroot, self.confighandlers = loader.loadURL(
                                           ~~~~~~~~~~~~~~^
        self.configfile)
        ^^^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/loader.py", line 153, in loadURL
    return self.loadResource(r)
           ~~~~~~~~~~~~~~~~~^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/loader.py", line 397, in loadResource
    self._parse_resource(sm, resource)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/loader.py", line 442, in _parse_resource
    parser.parse(matcher)
    ~~~~~~~~~~~~^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/cfgparser.py", line 69, in parse
    section = self.end_section(section, line[2:-1])
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/cfgparser.py", line 121, in end_section
    self.context.endSection(
    ~~~~~~~~~~~~~~~~~~~~~~~^
        prevsection, type_, name, section)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/loader.py", line 415, in endSection
    sectvalue = matcher.finish()
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/matcher.py", line 174, in finish
    return self.constuct()
           ~~~~~~~~~~~~~^^
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/matcher.py", line 222, in constuct
    v = v.convert(ci.datatype)
  File "/Users/username/path/to/addon/.venv/lib/python3.13/site-packages/ZConfig/info.py", line 56, in convert
    raise ZConfig.DataConversionError(e, self.value, self.position)
ZConfig.DataConversionError: The directory named as part of the path /Users/username/path/to/addon/instance/var/filestorage/Data.fs does not exist. (line 28, in file:///Users/username/path/to/addon/instance/etc/zope.conf)
make: *** [create-site] Error 1

It’s also unclear what make remove-data is intended to do:

  • Does it remove the entire site?
  • Or does it just clean out content/data while keeping the site itself intact?

This makes it difficult to know when and how to use the target safely.

Steps to Reproduce

  • Run make remove-data
  • Run make start or make create-site
  • Observe the errors above.

Expected Behavior

make remove-data should clearly state whether it removes the site or only clears its contents.

Running make start or make create-site afterward should not result in an error.

Solution Proposal

Add support for overriding instance.yaml with instance-local.yaml to better isolate and configure local instance data.

Such instance-local.yaml could look like this:

default_context:
    initial_user_name: 'admin'
    initial_user_password: 'admin'
    zcml_package_includes: 'backend.addon'
    db_storage: direct
    db_filestorage_location: ../data/filestorage/Data.fs
    db_blobs_location: ../data/blobstorage

This way you could store site content safely inside a e.g. data directory and have a Make target that specifically removes all content within that directory.

To complete this the instance/etc/zope.ini instance/etc/zope.conf: instance.yaml target in the Makefile would need to be updated with the following:

instance/etc/zope.ini instance/etc/zope.conf: instance.yaml ## Create instance configuration
	@echo "$(GREEN)==> Create instance configuration$(RESET)"
	## support overriding instance when instance-local.yaml exists
	if [[ -s instance-local.yaml ]]; then \
		echo ">>> Using instance-local.yaml"; \
		uvx cookiecutter -f --no-input -c 2.1.1 --config-file instance-local.yaml gh:plone/cookiecutter-zope-instance; \
	else \
		uvx cookiecutter -f --no-input -c 2.1.1 --config-file instance.yaml gh:plone/cookiecutter-zope-instance; \
	fi

/cc @fredvd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions