.. This README is meant for consumption by humans and pypi. Pypi can render rst files so please do not use Sphinx features.
If you want to learn more about writing documentation, please check out: http://docs.plone.org/about/documentation_styleguide.html
This text does not appear on pypi or github. It is a comment.
.. image:: https://coveralls.io/repos/github/plone/plone.autoinclude/badge.svg?branch=main
:target: https://coveralls.io/github/plone/plone.autoinclude?branch=main
:alt: Coveralls
.. image:: https://img.shields.io/pypi/l/plone.autoinclude.svg
:target: https://pypi.org/project/plone.autoinclude/
:alt: License
=================
plone.autoinclude
=================
Automatically include zcml of a package when it is loaded in a Plone site.
Features
--------
- It is an alternative to ``z3c.autoinclude``.
- When a package registers an autoinclude entry point, we load its Python code at Zope/Plone startup.
- And we load its zcml.
- Works with Buildout-installed packages.
- Works with pip-installed packages.
Compatibility
-------------
This is made for Python 3.6+.
Since Plone 6.0.0a2 it is included in core Plone.
See `PLIP 3339 <https://github.com/plone/Products.CMFPlone/issues/3339>`_.
It also works on Plone 5.2.
For add-on authors
------------------
When you have an existing package that has some zcml, you probably already have something like this in your ``setup.py``::
entry_points="""
[z3c.autoinclude.plugin]
target = plone
"""
or in a dictionary::
entry_points={
"z3c.autoinclude.plugin": [
"target = plone",
],
}
or in ``setup.cfg``::
[options.entry_points]
z3c.autoinclude.plugin =
target=plone
This still works!
You do not need to change anything.
But if you do not care about compatibility with ``z3c.autoinclude``, you could use this new entry point::
entry_points="""
[plone.autoinclude.plugin]
target = plone
"""
It does the same thing, but it only works with ``plone.autoinclude``.
Note: you should *not* add ``plone.autoinclude`` in your ``install_dependencies``.
It is the responsibility of the framework (usually Plone) to do this.
Entry point details
-------------------
This is an entry point with all options specified::
entry_points="""
[plone.autoinclude.plugin]
target = plone
module = example.alternative
"""
You must specify at least one option, otherwise the entry point does not exist.
``target``
In which framework should your zcml be loaded?
For a Plone add-on you would use ``plone``.
If Zope ever wants to use something similar, it could add configuration to look for packages with ``target="zope"``.
You can come up with targets yourself, and load them in a policy package, maybe: cms, frontend, companyname, customername, nl/de (language).
If target is empty, or the option is not there, the zcml will get loaded by all frameworks.
``module``
Use this when your package name is different from what you import in Python.
See also the next section.
Different project and module name
---------------------------------
Usually the project name of an add-on (what is in ``setup.py`` or ``setup.cfg``) is the same as how you would import it in Python code.
It could be different though.
In that case, you may get a ``ModuleNotFoundError`` on startup: ``plone.autoinclude`` tries to import the project name and this fails.
The easiest way to solve this, is to switch from ``z3c.autoinclude.plugin`` to ``plone.autoinclude.plugin``, if you have not done so already,
and specify the module.
In ``setup.py``::
setup(
name="example.different2",
entry_points="""
[plone.autoinclude.plugin]
module = example.somethingelse2
""",
)
If you must still support Plone 5.2 and are tied to ``z3c.autoinclude.plugin``, or if you cannot edit the problematic package, you can work around it.
You set an environment variable ``AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR``.
To accept ``ModuleNotFoundError`` in all packages::
export AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1
To accept ``ModuleNotFoundError`` only in specific packages, use a comma-separated list of project names, with or without spaces::
export AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=example.different,example.different2
In the logs you will see a traceback so you can investigate, but startup continues.
You should make sure the zcml of this package is loaded in some other way.
Comparison with ``z3c.autoinclude``
-----------------------------------
- ``z3c.autoinclude`` supports ``includeDependencies`` in a zcml file in your package.
This would look in the ``setup_requires`` of the package to find dependencies.
For each, it would load the zcml.
This can take quite long.
It might not work for packages installed by ``pip``, but this is not confirmed.
In the Plone community this is discouraged, and Plone already disables this in the tests.
``plone.autoinclude`` does not support this.
You should load the zcml of the dependencies explicitly in the ``configure.zcml`` of your package.
- ``z3c.autoinclude`` tries hard to find packages in non-standard places, installed in weird or old ways,
or with a module name that differs from the package name, with code especially suited for eggs that buildout installs.
``plone.autoinclude`` simply uses ``importlib.import_module`` on the module name.
If there is a mismatch between package name and module name, you can set ``module = modulename`` in your entry point.
- ``z3c.autoinclude`` does not support empty targets.
The target of the entry point must match the target that is being loaded.
``plone.autoinclude`` *does* support empty targets: they will always get loaded.
This is not good or bad, it is just a different choice.
- ``z3c.autoinclude`` supports disabling loading the plugins, via either an environment variable or an api call.
``plone.autoinclude`` does not.
But ``Products.CMFPlone`` currently loads the ``z3c.autoinclude`` plugins unless a zcml condition is true: ``not-have disable-autoinclude``.
When ``Products.CMFPlone`` switches to ``plone.autoinclude``, it can use this same condition.
In general, ``plone.autoinclude`` is a bit more modern, as it only started in 2020, and only supports Python 3.
Usage in Plone 5.2
------------------
Since Plone 6.0.0a2 this is included in core, so nothing needs to be done there.
If you want to use it in Plone 5.2, this is possible.
First add it to your buildout::
[instance]
...
eggs +=
plone.autoinclude
zcml +=
plone.autoinclude.ploneinclude-meta
plone.autoinclude.ploneinclude
plone.autoinclude.ploneinclude-overrides
This will include three zcml files from the ``ploneinclude`` directory.
It will do this:
- Disable the original z3c.autoinclude.
- Load CMFPlone meta.zcml, so the order in which zcml is loaded stays mostly the same.
- Load plone.autoinclude meta.zcml.
- Automatically include the meta.zcml of all plone plugins.
- Load CMFPlone configure.zcml.
- Automatically include the configure.zcml of all plone plugins.
- Load CMFPlone overrides.zcml.
- Automatically include the overrides.zcml of all plone plugins.
For other frameworks
--------------------
You can take the above section as example, and take care of the following
- Include the ``plone.autoinclude`` package in ``install_requires``.
- In your meta.zcml load the meta.zcml of plone.autoinclude.
- In your meta.zcml load the meta.zcml of your plugins:
``<autoIncludePlugins target="your-framework" file="meta.zcml" />``
- In your configure.zcml load the configure.zcml of your plugins:
``<autoIncludePlugins target="your-framework" file="configure.zcml" />``
- In your overrides.zcml load the meta.zcml of your plugins in override mode:
``<autoIncludePluginsOverrides target="your-framework" file="meta.zcml" />``
Installation with pip
---------------------
Let's leave buildout completely out of the picture and only use pip, in this case with plone 5.2.5.
We use the legacy resolver from pip, to avoid some possible problems that have nothing to do with autoinclude::
# Create virtual environment in the current directory:
python3.8 -mvenv .
# Install Plone and Paste:
bin/pip install -c https://dist.plone.org/release/5.2.5/constraints.txt Products.CMFPlone Paste --use-deprecated legacy-resolver
# Install plone.autoinclude from the current git checkout:
bin/pip install -e .
# or 'bin/pip install plone.autoinclude' to get the latest from PyPI.
# Create the Zope WSGI instance:
bin/mkwsgiinstance -d . -u admin:admin
# Copy our zcml that disables z3c.autoinclude and enables our own.
cp -a package-includes etc/
# Start Zope:
bin/runwsgi -v etc/zope.ini
Contribute or get support
-------------------------
- If you are having issues, please let us know in the issue tracker: https://github.com/plone/plone.autoinclude/issues
- The source code is on GitHub: https://github.com/plone/plone.autoinclude
License
-------
The project is licensed under the GPLv2.
Changelog
=========
.. You should *NOT* be adding new change log entries to this file.
You should create a file in the news directory instead.
For helpful instructions, please see:
https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst
.. towncrier release notes start
1.0.1 (2022-12-10)
------------------
Bug fixes:
- Revert "Use setuptools/pkg_resources regex to compute safe name for a project" to fix an error importing packages with dashes. [davisagli] (#22)
1.0.0 (2022-12-01)
------------------
Bug fixes:
- Use setuptools/pkg_resources regex to compute safe name for a project.
[gforcada] (#17)
1.0.0a5 (2022-05-24)
--------------------
New features:
- Raise an exception when a module is not found.
When environment variable ``AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1`` is set, we log an error and continue.
To accept ``ModuleNotFoundError`` only in specific packages, use a comma-separated list of project names, with or without spaces.
See `issue 19 <https://github.com/plone/plone.autoinclude/issues/19>`_.
[maurits] (#19)
1.0.0a4 (2022-02-23)
--------------------
Bug fixes:
- Replace dash with lowdash in project_name, as Python Project are normally divided by dash and modul name uses lowdash [MrTango] (#16)
1.0.0a3 (2021-12-03)
--------------------
Bug fixes:
- Decrease verbosity when loading packages (#11)
1.0.0a2 (2021-10-20)
--------------------
Bug fixes:
- Improved documentation, especially on how to include this.
Added zcml in a ploneinclude directory to make this easier for now.
[maurits] (#1)
1.0.0a1 (2021-10-15)
--------------------
New features:
- Initial release.
[maurits, tschorr]
Raw data
{
"_id": null,
"home_page": "https://github.com/collective/plone.autoinclude",
"name": "plone.autoinclude",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "Python Plone CMS",
"author": "Maurits van Rees",
"author_email": "maurits@vanrees.org",
"download_url": "https://files.pythonhosted.org/packages/a8/61/c3158766c66e5ce3be2a67404c8c569c6772aa90079d575cce8f9bc6db9f/plone.autoinclude-1.0.1.tar.gz",
"platform": null,
"description": ".. This README is meant for consumption by humans and pypi. Pypi can render rst files so please do not use Sphinx features.\n If you want to learn more about writing documentation, please check out: http://docs.plone.org/about/documentation_styleguide.html\n This text does not appear on pypi or github. It is a comment.\n\n.. image:: https://coveralls.io/repos/github/plone/plone.autoinclude/badge.svg?branch=main\n :target: https://coveralls.io/github/plone/plone.autoinclude?branch=main\n :alt: Coveralls\n\n.. image:: https://img.shields.io/pypi/l/plone.autoinclude.svg\n :target: https://pypi.org/project/plone.autoinclude/\n :alt: License\n\n\n=================\nplone.autoinclude\n=================\n\nAutomatically include zcml of a package when it is loaded in a Plone site.\n\nFeatures\n--------\n\n- It is an alternative to ``z3c.autoinclude``.\n- When a package registers an autoinclude entry point, we load its Python code at Zope/Plone startup.\n- And we load its zcml.\n- Works with Buildout-installed packages.\n- Works with pip-installed packages.\n\n\nCompatibility\n-------------\n\nThis is made for Python 3.6+.\nSince Plone 6.0.0a2 it is included in core Plone.\nSee `PLIP 3339 <https://github.com/plone/Products.CMFPlone/issues/3339>`_.\n\nIt also works on Plone 5.2.\n\n\nFor add-on authors\n------------------\n\nWhen you have an existing package that has some zcml, you probably already have something like this in your ``setup.py``::\n\n entry_points=\"\"\"\n [z3c.autoinclude.plugin]\n target = plone\n \"\"\"\n\nor in a dictionary::\n\n entry_points={\n \"z3c.autoinclude.plugin\": [\n \"target = plone\",\n ],\n }\n\nor in ``setup.cfg``::\n\n [options.entry_points]\n z3c.autoinclude.plugin =\n target=plone\n\nThis still works!\nYou do not need to change anything.\n\nBut if you do not care about compatibility with ``z3c.autoinclude``, you could use this new entry point::\n\n entry_points=\"\"\"\n [plone.autoinclude.plugin]\n target = plone\n \"\"\"\n\nIt does the same thing, but it only works with ``plone.autoinclude``.\n\nNote: you should *not* add ``plone.autoinclude`` in your ``install_dependencies``.\nIt is the responsibility of the framework (usually Plone) to do this.\n\n\nEntry point details\n-------------------\n\nThis is an entry point with all options specified::\n\n entry_points=\"\"\"\n [plone.autoinclude.plugin]\n target = plone\n module = example.alternative\n \"\"\"\n\nYou must specify at least one option, otherwise the entry point does not exist.\n\n``target``\n In which framework should your zcml be loaded?\n For a Plone add-on you would use ``plone``.\n If Zope ever wants to use something similar, it could add configuration to look for packages with ``target=\"zope\"``.\n You can come up with targets yourself, and load them in a policy package, maybe: cms, frontend, companyname, customername, nl/de (language).\n If target is empty, or the option is not there, the zcml will get loaded by all frameworks.\n\n``module``\n Use this when your package name is different from what you import in Python.\n See also the next section.\n\n\nDifferent project and module name\n---------------------------------\n\nUsually the project name of an add-on (what is in ``setup.py`` or ``setup.cfg``) is the same as how you would import it in Python code.\nIt could be different though.\nIn that case, you may get a ``ModuleNotFoundError`` on startup: ``plone.autoinclude`` tries to import the project name and this fails.\n\nThe easiest way to solve this, is to switch from ``z3c.autoinclude.plugin`` to ``plone.autoinclude.plugin``, if you have not done so already,\nand specify the module.\nIn ``setup.py``::\n\n setup(\n name=\"example.different2\",\n entry_points=\"\"\"\n [plone.autoinclude.plugin]\n module = example.somethingelse2\n \"\"\",\n )\n\nIf you must still support Plone 5.2 and are tied to ``z3c.autoinclude.plugin``, or if you cannot edit the problematic package, you can work around it.\nYou set an environment variable ``AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR``.\nTo accept ``ModuleNotFoundError`` in all packages::\n\n export AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1\n\nTo accept ``ModuleNotFoundError`` only in specific packages, use a comma-separated list of project names, with or without spaces::\n\n export AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=example.different,example.different2\n\nIn the logs you will see a traceback so you can investigate, but startup continues.\nYou should make sure the zcml of this package is loaded in some other way.\n\n\nComparison with ``z3c.autoinclude``\n-----------------------------------\n\n- ``z3c.autoinclude`` supports ``includeDependencies`` in a zcml file in your package.\n This would look in the ``setup_requires`` of the package to find dependencies.\n For each, it would load the zcml.\n This can take quite long.\n It might not work for packages installed by ``pip``, but this is not confirmed.\n In the Plone community this is discouraged, and Plone already disables this in the tests.\n ``plone.autoinclude`` does not support this.\n You should load the zcml of the dependencies explicitly in the ``configure.zcml`` of your package.\n- ``z3c.autoinclude`` tries hard to find packages in non-standard places, installed in weird or old ways,\n or with a module name that differs from the package name, with code especially suited for eggs that buildout installs.\n ``plone.autoinclude`` simply uses ``importlib.import_module`` on the module name.\n If there is a mismatch between package name and module name, you can set ``module = modulename`` in your entry point.\n- ``z3c.autoinclude`` does not support empty targets.\n The target of the entry point must match the target that is being loaded.\n ``plone.autoinclude`` *does* support empty targets: they will always get loaded.\n This is not good or bad, it is just a different choice.\n- ``z3c.autoinclude`` supports disabling loading the plugins, via either an environment variable or an api call.\n ``plone.autoinclude`` does not.\n But ``Products.CMFPlone`` currently loads the ``z3c.autoinclude`` plugins unless a zcml condition is true: ``not-have disable-autoinclude``.\n When ``Products.CMFPlone`` switches to ``plone.autoinclude``, it can use this same condition.\n\nIn general, ``plone.autoinclude`` is a bit more modern, as it only started in 2020, and only supports Python 3.\n\n\nUsage in Plone 5.2\n------------------\n\nSince Plone 6.0.0a2 this is included in core, so nothing needs to be done there.\nIf you want to use it in Plone 5.2, this is possible.\nFirst add it to your buildout::\n\n [instance]\n ...\n eggs +=\n plone.autoinclude\n zcml +=\n plone.autoinclude.ploneinclude-meta\n plone.autoinclude.ploneinclude\n plone.autoinclude.ploneinclude-overrides\n\nThis will include three zcml files from the ``ploneinclude`` directory.\nIt will do this:\n\n- Disable the original z3c.autoinclude.\n- Load CMFPlone meta.zcml, so the order in which zcml is loaded stays mostly the same.\n- Load plone.autoinclude meta.zcml.\n- Automatically include the meta.zcml of all plone plugins.\n- Load CMFPlone configure.zcml.\n- Automatically include the configure.zcml of all plone plugins.\n- Load CMFPlone overrides.zcml.\n- Automatically include the overrides.zcml of all plone plugins.\n\n\nFor other frameworks\n--------------------\n\nYou can take the above section as example, and take care of the following\n\n- Include the ``plone.autoinclude`` package in ``install_requires``.\n- In your meta.zcml load the meta.zcml of plone.autoinclude.\n- In your meta.zcml load the meta.zcml of your plugins:\n ``<autoIncludePlugins target=\"your-framework\" file=\"meta.zcml\" />``\n- In your configure.zcml load the configure.zcml of your plugins:\n ``<autoIncludePlugins target=\"your-framework\" file=\"configure.zcml\" />``\n- In your overrides.zcml load the meta.zcml of your plugins in override mode:\n ``<autoIncludePluginsOverrides target=\"your-framework\" file=\"meta.zcml\" />``\n\n\nInstallation with pip\n---------------------\n\nLet's leave buildout completely out of the picture and only use pip, in this case with plone 5.2.5.\nWe use the legacy resolver from pip, to avoid some possible problems that have nothing to do with autoinclude::\n\n # Create virtual environment in the current directory:\n python3.8 -mvenv .\n # Install Plone and Paste:\n bin/pip install -c https://dist.plone.org/release/5.2.5/constraints.txt Products.CMFPlone Paste --use-deprecated legacy-resolver\n # Install plone.autoinclude from the current git checkout:\n bin/pip install -e .\n # or 'bin/pip install plone.autoinclude' to get the latest from PyPI.\n # Create the Zope WSGI instance:\n bin/mkwsgiinstance -d . -u admin:admin\n # Copy our zcml that disables z3c.autoinclude and enables our own.\n cp -a package-includes etc/\n # Start Zope:\n bin/runwsgi -v etc/zope.ini\n\n\nContribute or get support\n-------------------------\n\n- If you are having issues, please let us know in the issue tracker: https://github.com/plone/plone.autoinclude/issues\n- The source code is on GitHub: https://github.com/plone/plone.autoinclude\n\n\nLicense\n-------\n\nThe project is licensed under the GPLv2.\n\nChangelog\n=========\n\n\n.. You should *NOT* be adding new change log entries to this file.\n You should create a file in the news directory instead.\n For helpful instructions, please see:\n https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst\n\n.. towncrier release notes start\n\n1.0.1 (2022-12-10)\n------------------\n\nBug fixes:\n\n\n- Revert \"Use setuptools/pkg_resources regex to compute safe name for a project\" to fix an error importing packages with dashes. [davisagli] (#22)\n\n\n1.0.0 (2022-12-01)\n------------------\n\nBug fixes:\n\n\n- Use setuptools/pkg_resources regex to compute safe name for a project.\n [gforcada] (#17)\n\n\n1.0.0a5 (2022-05-24)\n--------------------\n\nNew features:\n\n\n- Raise an exception when a module is not found.\n When environment variable ``AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1`` is set, we log an error and continue.\n To accept ``ModuleNotFoundError`` only in specific packages, use a comma-separated list of project names, with or without spaces.\n See `issue 19 <https://github.com/plone/plone.autoinclude/issues/19>`_.\n [maurits] (#19)\n\n\n1.0.0a4 (2022-02-23)\n--------------------\n\nBug fixes:\n\n\n- Replace dash with lowdash in project_name, as Python Project are normally divided by dash and modul name uses lowdash [MrTango] (#16)\n\n\n1.0.0a3 (2021-12-03)\n--------------------\n\nBug fixes:\n\n\n- Decrease verbosity when loading packages (#11)\n\n\n1.0.0a2 (2021-10-20)\n--------------------\n\nBug fixes:\n\n\n- Improved documentation, especially on how to include this.\n Added zcml in a ploneinclude directory to make this easier for now.\n [maurits] (#1)\n\n\n1.0.0a1 (2021-10-15)\n--------------------\n\nNew features:\n\n- Initial release.\n [maurits, tschorr]\n",
"bugtrack_url": null,
"license": "GPL version 2",
"summary": "Auto include code and zcml",
"version": "1.0.1",
"split_keywords": [
"python",
"plone",
"cms"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "ba6978019758dffc26d8e1115849f27c",
"sha256": "c7aa865ee409e7a083153d36d83f91c8ecfc9f06c1eefab634ab9f8a5d1e64eb"
},
"downloads": -1,
"filename": "plone.autoinclude-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba6978019758dffc26d8e1115849f27c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 20669,
"upload_time": "2022-12-10T02:19:25",
"upload_time_iso_8601": "2022-12-10T02:19:25.354649Z",
"url": "https://files.pythonhosted.org/packages/c2/b5/1d9bf94a796ffc17d918d71c5cedb357a167c4d07dd0458767962919017c/plone.autoinclude-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "acd841e38786578d77513787e8e5bbb0",
"sha256": "08f3d6c4b038ac5f5a0dd01fff201d9e71191bce14b5424b063bb8882ae6621a"
},
"downloads": -1,
"filename": "plone.autoinclude-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "acd841e38786578d77513787e8e5bbb0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 40521,
"upload_time": "2022-12-10T02:19:28",
"upload_time_iso_8601": "2022-12-10T02:19:28.067227Z",
"url": "https://files.pythonhosted.org/packages/a8/61/c3158766c66e5ce3be2a67404c8c569c6772aa90079d575cce8f9bc6db9f/plone.autoinclude-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-10 02:19:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "collective",
"github_project": "plone.autoinclude",
"lcname": "plone.autoinclude"
}