Aldryn – Adapting Add-On to a project’s requirements

How often does it happen: There is a perfect pre-made add-on / plugin available for your CMS however the web project has a specific requirement that this add-on doesnt quite meet.

The patching begins.

On Aldryn, currently there are some drawbacks with Add-On development:

  • Adding an add-on requires rebuilding the docker container and this is slow.
  • There is no way to “install” an existing add-on and then patch it, and include the changed code in the source code repository.
  • Forks of existing add-ons need to be public on github so that the deploy process can install them (with pip). That doesn’t fly for project-specific patched versions.

I have tested a way to make this patching process cleaner. Below I try to sketch it out.

It requires a virtualenv setup and the command line aldryn client.

  1. Now, a public add-on repo (like aldryn-events) can be duplicated (git clone & git rm remote origin, then add your own repo’s remote)
  2. This private ‘fork’ can now be cloned into Aldryn’s project /addons-dev.
  3. Install it by adding -e /absolute/path/to/Projects/project-name/addons-dev/project-name-aldryn-events to requirements.in and pip install -r requirements.in
  4. Add the app name to settings.py and maybe run ./manage.py migrate
  5. Now you can patch, test and commit to your own private repo.
  6. Once you are happy with the patched version you can go into /addons-dev/project-aldryn-events and aldryn addons register "Project Name Aldryn Events" project-aldryn-events and aldryn addons upload. From the Aldryn web console you can then install the new add-on into the system (in the virtualenv, do git pull and pip install -r requirements.in)
  7. For the installed addons to work the addons in addons-dev have to be renamed (I rename them to addon-name-dev).

Note: For easier upgrading it is even possible to diff the patched version with the original open source version:

  • add the original version as remote: `git remote add upstream git-url`
  • Then `git checkout -b original upstream/master`
  • Now a pull request between your patched branch and `original` can be made on github