Anatomy of a Divio Cloud addon

Basic file structure

For an addon “Susan Example Application”:

addons-dev/
    susan-example-application/
        addon.json
        LICENSE
        MANIFEST.in
        README.rst
        setup.py
        susan_example_application/
            __init__.py

aldryn_config.py

All addons have an aldryn_config.py file that takes care of settings, which are then loaded into settings.py.

This means that any settings you need to apply in a project can’t simply be applied in your settings.py if an addon also needs access to them.

For example, nearly every addon will add a package, or sometimes several, to INSTALLED_APPS. If you were to assign do INSTALLED_APPS = [...] in the usual way, you would overwrite the existing assignments and break the project. That’s why our settings.py uses:

INSTALLED_APPS.extend([
    # add your project specific apps here
])

The same goes for middleware, and other settings.

aldryn_config.py is loaded into the Django project at run-time, so any changes are picked up when and reloaded automatically when developing.

aldryn_config.py is an ideal place to check for environment variables that should be converted into Django settings.

See Application configuration with aldryn_config.py.

addon.json

A metadata file.

{
    "package-name": "susan-example-application",
    "installed-apps": [
        "susan_example_application"
    ]
}

setup.py

setup.py will be generated by the Control Panel on the basis of the information you provided when you first created it there. The lines highlighted below are those that will be specific to your addon:

# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from susan_example_application import __version__


setup(
    name='susan-example-application',
    version=__version__,
    description=open('README.rst').read(),
    author='Susan',
    author_email='[email protected]',
    packages=find_packages(),
    platforms=['OS Independent'],
    install_requires=["example_application==1.8.3"],
    include_package_data=True,
    zip_safe=False,
)