Skip to main content
https://travis-ci.org/aldryn/aldryn-apphook-reload.svg?branch=develop https://img.shields.io/coveralls/aldryn/aldryn-apphook-reload.svg

Reload urls of django CMS Apphooks without a restart

Introduction

Django CMS allows extending cms pages with Apphooks. Apphooks are saved in the Database, which means urls depend on the database contents. For changes to Apphooks to be reflected in reverse() and {% url ... %} calls, a webserver restart is usually necessary.

aldryn-apphook-reload will automatically reload urls from Django CMS apphooks, without the need of a webserver restart. It listens to cms.signals.urls_need_reloading and causes a reload.

The signal is only available in the process where the change to the database was made. In order for other processes to know when to reload (be it a gunicorn worker or a process on a other server) a token is saved in the database. This implies a performance hit: 1 database query per request.

Installation

  • add aldryn_apphook_reload to INSTALLED_APPS.

  • add aldryn_apphook_reload.middleware.ApphookReloadMiddleware to MIDDLEWARE (place it as close to the top as possible)

  • run migrations: python manage.py migrate aldryn_apphook_reload

Advanced

If the process that triggers cms.signals.urls_need_reloading is a simple runserver under load ( ~2 requests per second), the reload sometimes fails on the other processes. This might be due to an unknown race condition, where the token in the database is refreshed already, but the new apphooks are not in the database yet. The other processes would try to reload right away and would reload the old apphooks. Tests with gunicorn in the default mode and in the gevent mode worked fine though.

Why not save the token in the cache backend for better performance? - Because altering the cache would happen right away, before the database transaction is committed at the end of the request. Thus other process would reload their urls prematurely.

Release files for aldryn-apphook-reload 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aldryn-apphook-reload 0.3.0
File Size Uploaded
aldryn-apphook-reload-0.3.0.tar.gz 5.9 kB Details

Release files / aldryn-apphook-reload-0.3.0.tar.gz

Download URL aldryn-apphook-reload-0.3.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fa57b6a93773d945127299c113dcc10592769e8b2c13d3b0d226b8fa9a3a9212
BLAKE2b-256 checksum
How to use checksums
701c0eff6f962e4e4d354bb430565e68fde9398eea995bd9739225c45660312b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page