Repository: Kinto/kinto

Issue:
Add support for previous backend configuration values ?
```
  File "/home/mathieu/Code/Mozilla/kinto/kinto/core/initialization.py", line 534, in initialize
    config.include("kinto.core", route_prefix=api_version)
  File "/home/mathieu/Code/Mozilla/kinto/.venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 798, in include
    c(configurator)
  File "/home/mathieu/Code/Mozilla/kinto/kinto/core/__init__.py", line 151, in includeme
    step_func(config)
  File "/home/mathieu/Code/Mozilla/kinto/kinto/core/initialization.py", line 203, in setup_storage
    raise ConfigurationError("Invalid storage backend: %s" % backend)
pyramid.exceptions.ConfigurationError: Invalid storage backend: <cliquet.storage.postgresql.Storage object at 0x7fb490042690>
```



Discussion:
Yeah, I wasn't really sure how to handle this. I'd like to support the configuration values with a deprecation warning if that's possible, but I don't want to go to a lot of effort to make that happen. I'll check to see if there's a way to update the config before invoking the Pyramid configuration stuff.

Here https://github.com/Kinto/kinto/blob/master/kinto/core/initialization.py#L441-L483 is where we already tinker with settings...
Not an emergency, but we may have to at least make it super clear here: 
https://github.com/Kinto/kinto/releases/tag/3.0.0


Resolving patch:
diff --git a/kinto/core/initialization.py b/kinto/core/initialization.py
--- a/kinto/core/initialization.py
+++ b/kinto/core/initialization.py
@@ -472,6 +472,20 @@ def _prefixed_keys(key):
             names = "', '".join(defined)
             raise ValueError("Settings '%s' are in conflict." % names)
 
+        # Maintain backwards compatibility with old settings files that
+        # have backend settings like cliquet.foo (which is now
+        # kinto.core.foo).
+        unprefixed, _, _ = _prefixed_keys(key)
+        if unprefixed in ['storage_backend', 'cache_backend',
+                          'permission_backend'] and \
+                value.startswith('cliquet.'):
+            new_value = value.replace('cliquet.', 'kinto.core.')
+            logger.warn(
+                "Backend settings referring to cliquet are DEPRECATED. "
+                "Please update your {} setting to {} (was: {}).".format(
+                    key, new_value, value))
+            value = new_value
+
         # Override settings from OS env values.
         # e.g. HTTP_PORT, READINGLIST_HTTP_PORT, KINTO_HTTP_PORT
         from_env = utils.read_env(unprefixed, value)


Test patch:
diff --git a/kinto/tests/core/test_initialization.py b/kinto/tests/core/test_initialization.py
--- a/kinto/tests/core/test_initialization.py
+++ b/kinto/tests/core/test_initialization.py
@@ -169,6 +169,22 @@ def test_environment_can_specify_project_name(self):
         os.environ.pop(envkey)
         self.assertEqual(value, 'kinto.core.storage.redis')
 
+    def test_can_continue_to_use_cliquet_names(self):
+        settings = {
+            'kinto.permission_backend': 'cliquet.permission.memory'
+        }
+        with mock.patch('kinto.core.logger.warn') as mocked:
+            new_settings = self.settings(settings)
+            warning_message = ''.join([
+                "Backend settings referring to cliquet are DEPRECATED. ",
+                "Please update your kinto.permission_backend setting to ",
+                "kinto.core.permission.memory ",
+                "(was: cliquet.permission.memory).",
+                ])
+            mocked.assert_called_once_with(warning_message)
+            self.assertEqual(new_settings['permission_backend'],
+                             'kinto.core.permission.memory')
+
 
 class ApplicationWrapperTest(unittest.TestCase):