Пример #1
0
    def __new__(cls, *args, **kwargs):

        if 'app_label' in kwargs['queue_options']:
            if 'modl_name' in kwargs['queue_options']:

                from django.db.models.loading import cache
                mgr_attr = kwargs['queue_options'].get('manager', "objects")

                ModlCls = cache.get_model(
                    app_label=kwargs['queue_options'].get('app_label'),
                    model_name=kwargs['queue_options'].get('modl_name'))

                if ModlCls is not None:
                    mgr_instance = getattr(ModlCls, mgr_attr)
                    mgr_instance.runmode = kwargs.pop('runmode', None)
                    mgr_instance.queue_name = kwargs.pop('queue_name')
                    mgr_instance.queue_options = {}
                    mgr_instance.queue_options.update(
                        kwargs.pop('queue_options', {}))
                    return mgr_instance

                else:
                    return QueueBase()

            else:
                raise ImproperlyConfigured(
                    "DatabaseQueueProxy's queue configuration requires the name of a model class to be specified in in 'modl_name'."
                )

        else:
            raise ImproperlyConfigured(
                "DatabaseQueueProxy's queue configuration requires an app specified in 'app_label', in which the definition for a model named 'modl_name' can be found."
            )
Пример #2
0
 def __init__(self, *args, **kwargs):
     self.runmode = kwargs.get('runmode', 4)
     QueueBase.__init__(self, *args, **kwargs)
     DelegateManager.__init__(self, *args, **kwargs)
Пример #3
0
 def __init__(self, *args, **kwargs):
     self.runmode = kwargs.get('runmode', 4)
     QueueBase.__init__(self, *args, **kwargs)
     DelegateManager.__init__(self, *args, **kwargs)
Пример #4
0
 def __init__(self, *args, **kwargs):
     DelegateManager.__init__(self, *args, **kwargs)
     QueueBase.__init__(self, *args, **kwargs)