Browse Source

Renames all sqlalchemy_* settings to database_*

Ask Solem 8 years ago
parent
commit
56593ab2fd

+ 2 - 2
celery/app/defaults.py

@@ -188,8 +188,8 @@ NAMESPACES = Namespace(
         cert_store=Option(type='string'),
         key=Option(type='string'),
     ),
-    sqlalchemy=Namespace(
-        dburi=Option(old={'celery_result_dburi'}),
+    database=Namespace(
+        uri=Option(old={'celery_result_dburi'}),
         engine_options=Option(
             type='dict', old={'celery_result_engine_options'},
         ),

+ 5 - 5
celery/backends/database/__init__.py

@@ -75,22 +75,22 @@ class DatabaseBackend(BaseBackend):
         super(DatabaseBackend, self).__init__(
             expires_type=maybe_timedelta, url=url, **kwargs)
         conf = self.app.conf
-        self.url = url or dburi or conf.sqlalchemy_dburi
+        self.url = url or dburi or conf.database_url
         self.engine_options = dict(
             engine_options or {},
-            **conf.sqlalchemy_engine_options or {})
+            **conf.database_engine_options or {})
         self.short_lived_sessions = kwargs.get(
             'short_lived_sessions',
-            conf.sqlalchemy_short_lived_sessions)
+            conf.database_short_lived_sessions)
 
-        tablenames = conf.sqlalchemy_table_names or {}
+        tablenames = conf.database_table_names or {}
         Task.__table__.name = tablenames.get('task', 'celery_taskmeta')
         TaskSet.__table__.name = tablenames.get('group', 'celery_tasksetmeta')
 
         if not self.url:
             raise ImproperlyConfigured(
                 'Missing connection string! Do you have the'
-                ' sqlalchemy_dburi setting set to a real value?')
+                ' database_url setting set to a real value?')
 
     def ResultSession(self, session_manager=SessionManager()):
         return session_manager.session_factory(

+ 3 - 0
docs/conf.py

@@ -63,6 +63,9 @@ ignored_settings = {
     # MongoDB settings replaced by URL config.,
     'mongodb_backend_settings',
 
+    # Database URL replaced by URL config (result_backend = db+...).
+    'database_url',
+
     # Redis settings replaced by URL config.
     'redis_host',
     'redis_port',

+ 2 - 0
docs/django/first-steps-with-django.rst

@@ -154,6 +154,8 @@ concrete app instance:
 Extensions
 ==========
 
+.. _django-celery-results:
+
 ``django-celery-results`` - Using the Django ORM/Cache as a result backend
 --------------------------------------------------------------------------
 

+ 13 - 21
docs/userguide/configuration.rst

@@ -102,10 +102,10 @@ rush in moving to the new settings format.
 ``CELERY_TASK_RESULT_EXPIRES``         :setting:`result_expires`
 ``CELERY_RESULT_PERSISTENT``           :setting:`result_persistent`
 ``CELERY_RESULT_SERIALIZER``           :setting:`result_serializer`
-``CELERY_RESULT_DBURI``                :setting:`sqlalchemy_dburi`
-``CELERY_RESULT_ENGINE_OPTIONS``       :setting:`sqlalchemy_engine_options`
-``-*-_DB_SHORT_LIVED_SESSIONS``        :setting:`sqlalchemy_short_lived_sessions`
-``CELERY_RESULT_DB_TABLE_NAMES``       :setting:`sqlalchemy_db_names`
+``CELERY_RESULT_DBURI``                Use :setting:`result_backend` instead.
+``CELERY_RESULT_ENGINE_OPTIONS``       :setting:`database_engine_options`
+``[...]_DB_SHORT_LIVED_SESSIONS``      :setting:`database_short_lived_sessions`
+``CELERY_RESULT_DB_TABLE_NAMES``       :setting:`database_db_names`
 ``CELERY_SECURITY_CERTIFICATE``        :setting:`security_certificate`
 ``CELERY_SECURITY_CERT_STORE``         :setting:`security_cert_store`
 ``CELERY_SECURITY_KEY``                :setting:`security_key`
@@ -120,7 +120,7 @@ rush in moving to the new settings format.
 ``CELERY_DEFAULT_QUEUE``               :setting:`task_default_queue`
 ``CELERY_DEFAULT_RATE_LIMIT``          :setting:`task_default_rate_limit`
 ``CELERY_DEFAULT_ROUTING_KEY``         :setting:`task_default_routing_key`
-``-'-_EAGER_PROPAGATES_EXCEPTIONS``    :setting:`task_eager_propagates`
+``[...]_EAGER_PROPAGATES_EXCEPTIONS``  :setting:`task_eager_propagates`
 ``CELERY_IGNORE_RESULT``               :setting:`task_ignore_result`
 ``CELERY_TASK_PUBLISH_RETRY``          :setting:`task_publish_retry`
 ``CELERY_TASK_PUBLISH_RETRY_POLICY``   :setting:`task_publish_retry_policy`
@@ -697,17 +697,9 @@ strings (this is the part of the URI that comes after the ``db+`` prefix).
 .. _`Connection String`:
     http://www.sqlalchemy.org/docs/core/engines.html#database-urls
 
-.. setting:: sqlalchemy_dburi
+.. setting:: database_engine_options
 
-``sqlalchemy_dburi``
-~~~~~~~~~~~~~~~~~~~~
-
-This setting is no longer used as it's now possible to specify
-the database URL directly in the :setting:`result_backend` setting.
-
-.. setting:: sqlalchemy_engine_options
-
-``sqlalchemy_engine_options``
+``database_engine_options``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Default: ``{}`` (empty mapping).
@@ -716,11 +708,11 @@ To specify additional SQLAlchemy database engine options you can use
 the :setting:`sqlalchmey_engine_options` setting::
 
     # echo enables verbose logging from SQLAlchemy.
-    app.conf.sqlalchemy_engine_options = {'echo': True}
+    app.conf.database_engine_options = {'echo': True}
 
-.. setting:: sqlalchemy_short_lived_sessions
+.. setting:: database_short_lived_sessions
 
-``sqlalchemy_short_lived_sessions``
+``database_short_lived_sessions``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Default: Disabled by default.
@@ -732,9 +724,9 @@ going stale through inactivity. For example, intermittent errors like
 `(OperationalError) (2006, 'MySQL server has gone away')` can be fixed by enabling
 short lived sessions. This option only affects the database backend.
 
-.. setting:: sqlalchemy_table_names
+.. setting:: database_table_names
 
-``sqlalchemy_table_names``
+``database_table_names``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Default: ``{}`` (empty mapping).
@@ -746,7 +738,7 @@ you to customize the table names:
 .. code-block:: python
 
     # use custom table names for the database result backend.
-    sqlalchemy_table_names = {
+    database_table_names = {
         'task': 'myapp_taskmeta',
         'group': 'myapp_groupmeta',
     }

+ 17 - 6
docs/whatsnew-4.0.rst

@@ -249,10 +249,17 @@ we've removed them completely, breaking backwards compatibility.
 
 - Using the Django ORM as a broker is no longer supported.
 
+    You can still use the Django ORM as a result backend:
+    see :ref:`django-celery-results` section for more information.
+
 - Using SQLAlchemy as a broker is no longer supported.
 
+    You can still use SQLAlchemy as a result backend.
+
 - Using CouchDB as a broker is no longer supported.
 
+    You can still use CouchDB as a result backend.
+
 - Using IronMQ as a broker is no longer supported.
 
 - Using Beanstalk as a broker is no longer supported.
@@ -357,8 +364,12 @@ and save a backup in :file:`proj/settings.py.orig`.
     You can find the most up to date Django Celery integration example
     here: :ref:`django-first-steps`.
 
-    Note that this will also add a prefix to settings that didn't previously
-    have one, like ``BROKER_URL``.
+    .. note::
+
+        This will also add a prefix to settings that didn't previously
+        have one, for example ``BROKER_URL`` should be written
+        ``CELERY_BROKER_URL`` with a namespace of ``CELERY``
+        ``CELERY_BROKER_URL``.
 
     Luckily you don't have to manually change the files, as
     the :program:`celery upgrade settings --django` program should do the
@@ -386,10 +397,10 @@ a few special ones:
 ``CELERY_MAX_CACHED_RESULTS``          :setting:`result_cache_max`
 ``CELERY_MESSAGE_COMPRESSION``         :setting:`result_compression`/:setting:`task_compression`.
 ``CELERY_TASK_RESULT_EXPIRES``         :setting:`result_expires`
-``CELERY_RESULT_DBURI``                :setting:`sqlalchemy_dburi`
-``CELERY_RESULT_ENGINE_OPTIONS``       :setting:`sqlalchemy_engine_options`
-``-*-_DB_SHORT_LIVED_SESSIONS``        :setting:`sqlalchemy_short_lived_sessions`
-``CELERY_RESULT_DB_TABLE_NAMES``       :setting:`sqlalchemy_db_names`
+``CELERY_RESULT_DBURI``                :setting:`result_backend`
+``CELERY_RESULT_ENGINE_OPTIONS``       :setting:`database_engine_options`
+``-*-_DB_SHORT_LIVED_SESSIONS``        :setting:`database_short_lived_sessions`
+``CELERY_RESULT_DB_TABLE_NAMES``       :setting:`database_db_names`
 ``CELERY_ACKS_LATE``                   :setting:`task_acks_late`
 ``CELERY_ALWAYS_EAGER``                :setting:`task_always_eager`
 ``CELERY_ANNOTATIONS``                 :setting:`task_annotations`

+ 2 - 2
t/unit/app/test_app.py

@@ -632,14 +632,14 @@ class test_App:
                    'worker_prefetch_multiplier=368',
                    '.foobarstring=(string)300',
                    '.foobarint=(int)300',
-                   'sqlalchemy_engine_options=(dict){"foo": "bar"}']
+                   'database_engine_options=(dict){"foo": "bar"}']
         self.app.config_from_cmdline(cmdline, namespace='worker')
         assert not self.app.conf.task_always_eager
         assert self.app.conf.result_backend == '/dev/null'
         assert self.app.conf.worker_prefetch_multiplier == 368
         assert self.app.conf.worker_foobarstring == '300'
         assert self.app.conf.worker_foobarint == 300
-        assert self.app.conf.sqlalchemy_engine_options == {'foo': 'bar'}
+        assert self.app.conf.database_engine_options == {'foo': 'bar'}
 
     def test_setting__broker_transport_options(self):
 

+ 1 - 1
t/unit/backends/test_database.py

@@ -73,7 +73,7 @@ class test_DatabaseBackend:
         assert calls[0] == 5
 
     def test_missing_dburi_raises_ImproperlyConfigured(self):
-        self.app.conf.sqlalchemy_dburi = None
+        self.app.conf.database_url = None
         with pytest.raises(ImproperlyConfigured):
             DatabaseBackend(app=self.app)