Преглед на файлове

Moves mongodb Bunch to celery.utils.objects

Ask Solem преди 9 години
родител
ревизия
88bc049542
променени са 2 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 1 6
      celery/backends/mongodb.py
  2. 7 0
      celery/utils/objects.py

+ 1 - 6
celery/backends/mongodb.py

@@ -16,6 +16,7 @@ from kombu.utils import cached_property
 from celery import states
 from celery.exceptions import ImproperlyConfigured
 from celery.five import items, string_t
+from celery.utils.objects import Bunch
 from celery.utils.timeutils import maybe_timedelta
 
 from .base import BaseBackend
@@ -36,12 +37,6 @@ else:                                       # pragma: no cover
 __all__ = ['MongoBackend']
 
 
-class Bunch(object):
-
-    def __init__(self, **kw):
-        self.__dict__.update(kw)
-
-
 class MongoBackend(BaseBackend):
     host = 'localhost'
     port = 27017

+ 7 - 0
celery/utils/objects.py

@@ -11,6 +11,13 @@ from __future__ import absolute_import
 __all__ = ['mro_lookup']
 
 
+class Bunch(object):
+    """Object that enables you to modify attributes."""
+
+    def __init__(self, **kwargs):
+        self.__dict__.update(kwargs)
+
+
 def mro_lookup(cls, attr, stop=(), monkey_patched=[]):
     """Return the first node by MRO order that defines an attribute.