Skip to main content

Experiment for configuring with venusian instead of *.zcml

Project description

venusianconfiguration

This package (venusianconfiguration) provides venusian based Python configuration syntax for zope.configuration as an alternative to zcml. This package does not replace zope.configuration like grok used to do, but just provides generic Python bindings for existing zope.configuration directives. So, venusianconfiguration is more an alternative to grok than it is to zope.configuration.

The current status of this package can be described as already in internal use, but maybe not yet ready for the community.

https://travis-ci.org/datakurre/collective.venusianconfig.png

The good:

from venusianconfiguration import configure

configure.i18n.registerTranslations(directory='locales')

@configure.browser.page.klass(
    name='hello-world', for_=Interface,
    permission='zope2.View')
class HelloWorld(BrowserView):
    def __call__(self):
        return u'Hello world!'

@configure.plone.behavior.provides(
    title=_(u'My behavior),
    description=_(u'Enables magic'))
class IMyBehavior(model.Schema):
    custom_field = schema.TextLine()
alsoProvides(IMyBehavior, IFormFieldProvider)

The bad:

from venusianconfiguration import scan
from venusianconfiguration import configure

from mypackage import browser
scan(browser)

import zcmlpackage
configure.include(package=zcmlpackage)

import otherpypackage
configure.include(package=otherpypackage, file='configure.py')

import mypackage.submodule
configure.include(package=mypackage.submodule,
                  file='configure.py')

The ugly:

zope.configuration is mostly syntax-agnostic, but unfortunately ZCML has been the only implemented syntax for it and we have also used to call its ZCML-specific API directly (e.g. in test fixtures and in z3c.autoinclude).

Therefore a new zope.configuration syntax cannot be introduced outside zope.configuration without monkeypatching…

venusianconfiguration works by monkeypatching the processxmlfile method in zope.configuration’s ZCML-support to accept also Python files pass those to venusianconfiguration to process.

To support z3c.autoinclude, venusianconfiguration also monkeypatches z3c.autoincludes’s includePluginsDirective and includePluginsOveridesDirective (includeDependencies-directive is considered evil and is intentionally left unsupported).

So, three monkeypatches in total for zcml-free configuration.

Usage

[instance]
recipe = plone.recipe.zope2instance
...
eggs =
    ...
    venusianconfiguration
zope-conf-additional =
    # Enable venuasianconfiguration monkeypatches
    %import venusianconfiguration

For more examples, look into the demo-package included in the sources.

Troubleshooting

Because the configuration now written in Python, your add-on must have its namespaces packages properly defined in its setup.py. E.g. add-on called my.product would have following namespace package definition:

setup(
    ...
    namespace_packages=['my'],
    ...
 )

Even there’s no ZCML, the add-on must be registered to be configured. This can be done by adding the usual z3c.autoinclude-entrypoint into add-on’s setup.py:

setup(
    ...
    entry_points="""
    # -*- Entry points: -*-
    [z3c.autoinclude.plugin]
    target = plone
    """
)

An alternative would be to add the package into the zcml-option of your Plone instance’s buildout-part for plone.recipe.zope2instance:

[instance]
recipe=plone.recipe.zope2instance
...
zcml = my.product

Changelog

1.0.2 (2017-12-21)

  • Fix issue where default configuration directive being mutable caused unexpected behavior [datakurre]

1.0.1 (2016-09-21)

  • Fix issue where zope.deferredimported module was not recognized as module [datakurre]

1.0.0 (2016-04-19)

  • First release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

venusianconfiguration-1.0.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

venusianconfiguration-1.0.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

venusianconfiguration-1.0.2-py2.py3-none-any.whl (12.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file venusianconfiguration-1.0.2.tar.gz.

File metadata

File hashes

Hashes for venusianconfiguration-1.0.2.tar.gz
Algorithm Hash digest
SHA256 88a0adf08a02d86cb5903bfbfe3eb059aeead1000d07afd500735ed792273e5d
MD5 ec72f5237f52e1334442ad187dc0ba48
BLAKE2b-256 08ae0e5df8e563499ff21803056c9f5b5e17786ea695e8eb45aba81629cec928

See more details on using hashes here.

File details

Details for the file venusianconfiguration-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for venusianconfiguration-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a5416ecbe14188e3633d9e6e26edbd77035fe2a2d6322f6f700a9b0771dff421
MD5 ffedb33e40f0db1cbf2a1987c5bd6692
BLAKE2b-256 7d6cc5322489b28de023dec47f82345de5ff9d1982e975403e8a0c5f1786522a

See more details on using hashes here.

File details

Details for the file venusianconfiguration-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for venusianconfiguration-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 65acb96227e7333c709cd02b11825ecfb52ae00214753bbd1eac0aa06004b9ff
MD5 6ad4d054e7bd2fa49a063d897dc32da7
BLAKE2b-256 690b1e50a40d26818ce24c5399b3558648a9754839b222570f868d77e6c77937

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page