Browse Source

Some more minor django references removed

Ask Solem 15 years ago
parent
commit
07b299cf92

+ 2 - 2
celery/backends/__init__.py

@@ -26,7 +26,7 @@ def get_backend_cls(backend):
 """
 .. function:: get_default_backend_cls()
 
-    Get the backend class specified in :setting:`CELERY_RESULT_BACKEND`.
+    Get the backend class specified in the ``CELERY_RESULT_BACKEND`` setting.
 
 """
 get_default_backend_cls = curry(get_backend_cls, conf.RESULT_BACKEND)
@@ -36,7 +36,7 @@ get_default_backend_cls = curry(get_backend_cls, conf.RESULT_BACKEND)
 .. class:: DefaultBackend
 
     The default backend class used for storing task results and status,
-    specified in :setting:`CELERY_RESULT_BACKEND`.
+    specified in the ``CELERY_RESULT_BACKEND`` setting.
 
 """
 DefaultBackend = get_default_backend_cls()

+ 1 - 1
celery/backends/pyredis.py

@@ -25,7 +25,7 @@ class RedisBackend(KeyValueStoreBackend):
         The port to the Redis server.
 
         Raises :class:`celery.exceptions.ImproperlyConfigured` if
-        :setting:`REDIS_HOST` or :setting:`REDIS_PORT` is not set.
+        the ``REDIS_HOST`` or ``REDIS_PORT`` settings is not set.
 
     """
     redis_host = "localhost"

+ 0 - 1
celery/db/models.py

@@ -3,7 +3,6 @@ from datetime import datetime
 from sqlalchemy import Column, Sequence, ForeignKey
 from sqlalchemy import Integer, String, Text, DateTime, PickleType
 from sqlalchemy.orm import relation
-from sqlalchemy.ext.declarative import declarative_base
 
 from celery import states
 from celery.db.session import ResultModelBase

+ 3 - 1
celery/loaders/default.py

@@ -1,4 +1,5 @@
 import os
+from importlib import import_module
 
 from celery.loaders.base import BaseLoader
 
@@ -10,6 +11,7 @@ DEFAULT_SETTINGS = {
     "DATABASE_ENGINE": "sqlite3",
     "DATABASE_NAME": "celery.sqlite",
     "INSTALLED_APPS": ("celery", ),
+    "CELERY_IMPORTS": (),
 }
 
 
@@ -49,7 +51,7 @@ class Loader(BaseLoader):
         celery and Django so it can be used by regular Python."""
         configname = os.environ.get("CELERY_CONFIG_MODULE",
                                     DEFAULT_CONFIG_MODULE)
-        celeryconfig = __import__(configname, {}, {}, [''])
+        celeryconfig = import_module(configname)
         usercfg = dict((key, getattr(celeryconfig, key))
                             for key in dir(celeryconfig)
                                 if wanted_module_item(key))

+ 4 - 22
celery/tests/test_loaders.py

@@ -60,22 +60,6 @@ class TestLoaderBase(unittest.TestCase):
                               [os, sys, task])
 
 
-def modifies_django_env(fun):
-
-    def _protected(*args, **kwargs):
-        from django.conf import settings
-        current = dict((key, getattr(settings, key))
-                        for key in settings.get_all_members()
-                            if key.isupper())
-        try:
-            return fun(*args, **kwargs)
-        finally:
-            for key, value in current.items():
-                setattr(settings, key, value)
-
-    return _protected
-
-
 class TestDefaultLoader(unittest.TestCase):
 
     def test_wanted_module_item(self):
@@ -84,7 +68,6 @@ class TestDefaultLoader(unittest.TestCase):
         self.assertFalse(default.wanted_module_item("_foo"))
         self.assertFalse(default.wanted_module_item("__foo"))
 
-    @modifies_django_env
     def test_read_configuration(self):
         from types import ModuleType
 
@@ -93,17 +76,16 @@ class TestDefaultLoader(unittest.TestCase):
 
         celeryconfig = ConfigModule("celeryconfig")
         celeryconfig.CELERY_IMPORTS = ("os", "sys")
+        configname = os.environ.get("CELERY_CONFIG_MODULE") or "celeryconfig"
 
-        sys.modules["celeryconfig"] = celeryconfig
+        prevconfig = sys.modules[configname]
+        sys.modules[configname] = celeryconfig
         try:
             l = default.Loader()
             settings = l.read_configuration()
             self.assertTupleEqual(settings.CELERY_IMPORTS, ("os", "sys"))
-            from django.conf import settings
-            settings.configured = False
             settings = l.read_configuration()
             self.assertTupleEqual(settings.CELERY_IMPORTS, ("os", "sys"))
-            self.assertTrue(settings.configured)
             l.on_worker_init()
         finally:
-            sys.modules.pop("celeryconfig", None)
+            sys.modules[configname] = prevconfig

+ 0 - 112
docs/_ext/djangodocs.py

@@ -1,112 +0,0 @@
-"""
-Sphinx plugins for Django documentation.
-"""
-
-import docutils.nodes
-import docutils.transforms
-import sphinx
-import sphinx.addnodes
-import sphinx.directives
-import sphinx.environment
-import sphinx.roles
-from docutils import nodes
-
-
-def setup(app):
-    app.add_crossref_type(
-        directivename = "setting",
-        rolename = "setting",
-        indextemplate = "pair: %s; setting",
-    )
-    app.add_crossref_type(
-        directivename = "templatetag",
-        rolename = "ttag",
-        indextemplate = "pair: %s; template tag",
-    )
-    app.add_crossref_type(
-        directivename = "templatefilter",
-        rolename = "tfilter",
-        indextemplate = "pair: %s; template filter",
-    )
-    app.add_crossref_type(
-        directivename = "fieldlookup",
-        rolename = "lookup",
-        indextemplate = "pair: %s, field lookup type",
-    )
-    app.add_description_unit(
-        directivename = "django-admin",
-        rolename = "djadmin",
-        indextemplate = "pair: %s; django-admin command",
-        parse_node = parse_django_admin_node,
-    )
-    app.add_description_unit(
-        directivename = "django-admin-option",
-        rolename = "djadminopt",
-        indextemplate = "pair: %s; django-admin command-line option",
-        parse_node = lambda env, sig, signode: \
-                sphinx.directives.parse_option_desc(signode, sig),
-    )
-    app.add_config_value('django_next_version', '0.0', True)
-    app.add_directive('versionadded', parse_version_directive, 1, (1, 1, 1))
-    app.add_directive('versionchanged', parse_version_directive, 1, (1, 1, 1))
-    app.add_transform(SuppressBlockquotes)
-
-
-def parse_version_directive(name, arguments, options, content, lineno,
-                      content_offset, block_text, state, state_machine):
-    env = state.document.settings.env
-    is_nextversion = env.config.django_next_version == arguments[0]
-    ret = []
-    node = sphinx.addnodes.versionmodified()
-    ret.append(node)
-    if not is_nextversion:
-        if len(arguments) == 1:
-            linktext = 'Please, see the release notes <releases-%s>' % (
-                    arguments[0])
-            xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext,
-                                               lineno, state)
-            node.extend(xrefs[0])
-        node['version'] = arguments[0]
-    else:
-        node['version'] = "Development version"
-    node['type'] = name
-    if len(arguments) == 2:
-        inodes, messages = state.inline_text(arguments[1], lineno+1)
-        node.extend(inodes)
-        if content:
-            state.nested_parse(content, content_offset, node)
-        ret = ret + messages
-    env.note_versionchange(node['type'], node['version'], node, lineno)
-    return ret
-
-
-class SuppressBlockquotes(docutils.transforms.Transform):
-    """
-    Remove the default blockquotes that encase indented list, tables, etc.
-    """
-    default_priority = 300
-
-    suppress_blockquote_child_nodes = (
-        docutils.nodes.bullet_list,
-        docutils.nodes.enumerated_list,
-        docutils.nodes.definition_list,
-        docutils.nodes.literal_block,
-        docutils.nodes.doctest_block,
-        docutils.nodes.line_block,
-        docutils.nodes.table,
-    )
-
-    def apply(self):
-        for node in self.document.traverse(docutils.nodes.block_quote):
-            if len(node.children) == 1 and \
-                    isinstance(node.children[0],
-                               self.suppress_blockquote_child_nodes):
-                node.replace_self(node.children[0])
-
-
-def parse_django_admin_node(env, sig, signode):
-    command = sig.split(' ')[0]
-    env._django_curr_admin_command = command
-    title = "django-admin.py %s" % sig
-    signode += sphinx.addnodes.desc_name(title, title)
-    return sig

+ 2 - 9
docs/conf.py

@@ -6,20 +6,13 @@ import os
 # If your extensions are in another directory, add it here. If the directory
 # is relative to the documentation root, use os.path.abspath to make it
 # absolute, like shown here.
-sys.path.append("../celery")
-sys.path.append("../tests")
-import settings
-from django.core.management import setup_environ
-from django.conf import settings as dsettings
-setup_environ(settings)
-dsettings.configure()
+sys.path.append(os.path.join(os.pardir, "tests"))
 import celery
-sys.path.append(os.path.join(os.path.dirname(__file__), "_ext"))
 
 # General configuration
 # ---------------------
 
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'djangodocs']
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage']
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['.templates']

+ 1 - 1
docs/reference/celery.conf.rst

@@ -230,7 +230,7 @@ Configuration - celery.conf
 .. data:: CELERYD_POOL
 
     Name of the task pool class used by the worker.
-    Default is ``"celery.worker.pool.TaskPool"`.
+    Default is ``"celery.worker.pool.TaskPool"``.
 
 .. data:: CELERYD_LISTENER
 

+ 0 - 1
docs/reference/index.rst

@@ -30,5 +30,4 @@
     celery.events
     celery.bin.celeryd
     celery.bin.celerybeat
-    celery.bin.celeryinit
     celery.bin.camqadm

+ 0 - 4
examples/README.rst

@@ -7,10 +7,6 @@
 
 Example Python project using celery.
 
-* django
-
-Example Django project using celery.
-
 * httpexample
 
 Example project using remote tasks (webhook tasks)

+ 1 - 1
examples/celery_http_gateway/settings.py

@@ -95,5 +95,5 @@ INSTALLED_APPS = (
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
-    'celery',
+    'djcelery',
 )

+ 1 - 1
examples/celery_http_gateway/urls.py

@@ -1,7 +1,7 @@
 from django.conf.urls.defaults import *
 
 from celery.task.builtins import PingTask
-from celery import views as celery_views
+from djcelery import views as celery_views
 
 # Uncomment the next two lines to enable the admin:
 # from django.contrib import admin

+ 0 - 2
setup.cfg

@@ -17,9 +17,7 @@ upload-dir = docs/.build/html
 requires = python-uuid
            python-importlib
            python-multiprocessing==2.6.2.1
-           python-django
            python-dateutil
            python-anyjson
            python-carrot>=0.10.4
-           python-django-picklefield
            python-billiard>=0.3.0

+ 0 - 1
setup.py

@@ -77,7 +77,6 @@ setup(
     test_suite="nose.collector",
     classifiers=[
         "Development Status :: 5 - Production/Stable",
-        "Framework :: Django",
         "Operating System :: OS Independent",
         "Programming Language :: Python",
         "Environment :: No Input/Output (Daemon)",

+ 2 - 1
tests/celeryconfig.py

@@ -13,4 +13,5 @@ CELERY_SEND_TASK_ERROR_EMAILS = False
 @atexit.register
 def teardown_testdb():
     import os
-    os.remove("test.db")
+    if os.path.exists("test.db"):
+        os.remove("test.db")