Просмотр исходного кода

Drop caching_config from plugin configuration

jeremystretch 4 лет назад
Родитель
Сommit
f683f0786e

+ 1 - 30
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 |
 | `min_version` | Minimum version of NetBox with which the plugin is compatible |
 | `max_version` | Maximum 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 |
 | `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`) |
 | `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`) |
 | `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]
 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.
+```

+ 2 - 0
docs/release-notes/version-3.0.md

@@ -5,6 +5,7 @@
 ### Breaking Changes
 ### 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.
 * 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
 ### 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
 * [#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
 * [#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
 * [#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
 ### REST API Changes
 
 

+ 0 - 5
netbox/extras/plugins/__init__.py

@@ -47,11 +47,6 @@ class PluginConfig(AppConfig):
     # Middleware classes provided by the plugin
     # Middleware classes provided by the plugin
     middleware = []
     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
     # Default integration paths. Plugin authors can override these to customize the paths to
     # integrated components.
     # integrated components.
     template_extensions = 'template_content.template_extensions'
     template_extensions = 'template_content.template_extensions'

+ 0 - 6
netbox/extras/tests/test_plugins.py

@@ -80,12 +80,6 @@ class PluginTest(TestCase):
         """
         """
         self.assertIn('extras.tests.dummy_plugin.middleware.DummyMiddleware', settings.MIDDLEWARE)
         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):
     def test_min_version(self):
         """
         """
         Check enforcement of minimum NetBox version.
         Check enforcement of minimum NetBox version.

+ 0 - 9
netbox/netbox/settings.py

@@ -632,12 +632,3 @@ for plugin_name in PLUGINS:
     plugin_middleware = plugin_config.middleware
     plugin_middleware = plugin_config.middleware
     if plugin_middleware and type(plugin_middleware) in (list, tuple):
     if plugin_middleware and type(plugin_middleware) in (list, tuple):
         MIDDLEWARE.extend(plugin_middleware)
         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()
-    })