From f683f0786e58e11eb06057644dca3e828bb42ea4 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 7 Jul 2021 17:04:21 -0400 Subject: [PATCH] Drop caching_config from plugin configuration --- docs/plugins/development.md | 31 +---------------------------- docs/release-notes/version-3.0.md | 2 ++ netbox/extras/plugins/__init__.py | 5 ----- netbox/extras/tests/test_plugins.py | 6 ------ netbox/netbox/settings.py | 9 --------- 5 files changed, 3 insertions(+), 50 deletions(-) diff --git a/docs/plugins/development.md b/docs/plugins/development.md index f008da2fb..edeb4a2eb 100644 --- a/docs/plugins/development.md +++ b/docs/plugins/development.md @@ -113,7 +113,6 @@ NetBox looks for the `config` variable within a plugin's `__init__.py` to load i | `min_version` | Minimum version of NetBox with which the plugin is compatible | | `max_version` | Maximum version of NetBox with which the plugin is compatible | | `middleware` | A list of middleware classes to append after NetBox's build-in middleware | -| `caching_config` | Plugin-specific cache configuration | `template_extensions` | The dotted path to the list of template extension classes (default: `template_content.template_extensions`) | | `menu_items` | The dotted path to the list of menu items provided by the plugin (default: `navigation.menu_items`) | @@ -384,32 +383,4 @@ class SiteAnimalCount(PluginTemplateExtension): }) template_extensions = [SiteAnimalCount] -``` - -## Caching Configuration - -By default, all query operations within a plugin are cached. To change this, define a caching configuration under the PluginConfig class' `caching_config` attribute. All configuration keys will be applied within the context of the plugin; there is no need to include the plugin name. An example configuration is below: - -```python -class MyPluginConfig(PluginConfig): - ... - caching_config = { - 'foo': { - 'ops': 'get', - 'timeout': 60 * 15, - }, - '*': { - 'ops': 'all', - } - } -``` - -To disable caching for your plugin entirely, set: - -```python -caching_config = { - '*': None -} -``` - -See the [django-cacheops](https://github.com/Suor/django-cacheops) documentation for more detail on configuring caching. +``` \ No newline at end of file diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index f408bae6b..0c4674797 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -5,6 +5,7 @@ ### Breaking Changes * The default CSV export format for all objects now includes all available data. Additionally, the CSV headers now use human-friendly titles rather than the raw field names. +* Support for queryset caching configuration (`caching_config`) has been removed from the plugins API (see [#6639](https://github.com/netbox-community/netbox/issues/6639)). ### New Features @@ -64,6 +65,7 @@ CustomValidator can also be subclassed to enforce more complex logic by overridi * [#5994](https://github.com/netbox-community/netbox/issues/5994) - Drop support for `display_field` argument on ObjectVar * [#6068](https://github.com/netbox-community/netbox/issues/6068) - Drop support for legacy static CSV export * [#6338](https://github.com/netbox-community/netbox/issues/6338) - Decimal fields are no longer coerced to strings in REST API +* [#6639](https://github.com/netbox-community/netbox/issues/6639) - Drop support for queryset caching (django-cacheops) ### REST API Changes diff --git a/netbox/extras/plugins/__init__.py b/netbox/extras/plugins/__init__.py index 0ea461344..a4d61f017 100644 --- a/netbox/extras/plugins/__init__.py +++ b/netbox/extras/plugins/__init__.py @@ -47,11 +47,6 @@ class PluginConfig(AppConfig): # Middleware classes provided by the plugin middleware = [] - # Cacheops configuration. Cache all operations by default. - caching_config = { - '*': {'ops': 'all'}, - } - # Default integration paths. Plugin authors can override these to customize the paths to # integrated components. template_extensions = 'template_content.template_extensions' diff --git a/netbox/extras/tests/test_plugins.py b/netbox/extras/tests/test_plugins.py index b47453aa7..00a385bf5 100644 --- a/netbox/extras/tests/test_plugins.py +++ b/netbox/extras/tests/test_plugins.py @@ -80,12 +80,6 @@ class PluginTest(TestCase): """ self.assertIn('extras.tests.dummy_plugin.middleware.DummyMiddleware', settings.MIDDLEWARE) - def test_caching_config(self): - """ - Check that plugin caching configuration is registered. - """ - self.assertIn('extras.tests.dummy_plugin.*', settings.CACHEOPS) - def test_min_version(self): """ Check enforcement of minimum NetBox version. diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 9014ac656..2b7ca50b8 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -632,12 +632,3 @@ for plugin_name in PLUGINS: plugin_middleware = plugin_config.middleware if plugin_middleware and type(plugin_middleware) in (list, tuple): MIDDLEWARE.extend(plugin_middleware) - - # Apply cacheops config - if type(plugin_config.caching_config) is not dict: - raise ImproperlyConfigured( - "Plugin {} caching_config must be a dictionary.".format(plugin_name) - ) - CACHEOPS.update({ - "{}.{}".format(plugin_name, key): value for key, value in plugin_config.caching_config.items() - })