@@ -23,7 +23,6 @@ from xblock.plugin import default_select
|
||||
from .exceptions import InvalidLocationError, InsufficientSpecificationError
|
||||
from xmodule.errortracker import make_error_tracker
|
||||
from xmodule.assetstore import AssetMetadata
|
||||
from xmodule.modulestore.django import NullSignalHandler
|
||||
from opaque_keys.edx.keys import CourseKey, UsageKey, AssetKey
|
||||
from opaque_keys.edx.locations import Location # For import backwards compatibility
|
||||
from xblock.runtime import Mixologist
|
||||
@@ -155,6 +154,17 @@ class ActiveBulkThread(threading.local):
|
||||
self.records = defaultdict(bulk_ops_record_type)
|
||||
|
||||
|
||||
class NullSignalHandler(object):
|
||||
"""
|
||||
A null handler that does nothing
|
||||
"""
|
||||
def send(self, *args, **kwargs):
|
||||
"""
|
||||
No-op
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class BulkOperationsMixin(object):
|
||||
"""
|
||||
This implements the :meth:`bulk_operations` modulestore semantics which handles nested invocations
|
||||
@@ -170,7 +180,23 @@ class BulkOperationsMixin(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BulkOperationsMixin, self).__init__(*args, **kwargs)
|
||||
self._active_bulk_ops = ActiveBulkThread(self._bulk_ops_record_type)
|
||||
self.signal_handler = NullSignalHandler()
|
||||
self._signal_handler = None
|
||||
|
||||
@property
|
||||
def signal_handler(self):
|
||||
"""
|
||||
Return a signal handler, defaults to a null handler that does nothing.
|
||||
"""
|
||||
if not self._signal_handler:
|
||||
self._signal_handler = NullSignalHandler()
|
||||
return self._signal_handler
|
||||
|
||||
@signal_handler.setter
|
||||
def signal_handler(self, value):
|
||||
"""
|
||||
Set the signal handler
|
||||
"""
|
||||
self._signal_handler = value
|
||||
|
||||
@contextmanager
|
||||
def bulk_operations(self, course_id, emit_signals=True):
|
||||
|
||||
@@ -110,17 +110,6 @@ class SignalHandler(object):
|
||||
log.info('Sent %s signal to %s with kwargs %s. Response was: %s', signal_name, receiver, kwargs, response)
|
||||
|
||||
|
||||
class NullSignalHandler(object):
|
||||
"""
|
||||
A null handler that does nothing
|
||||
"""
|
||||
def send(self, *args, **kwargs):
|
||||
"""
|
||||
No-op
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def load_function(path):
|
||||
"""
|
||||
Load a function by name.
|
||||
|
||||
@@ -49,7 +49,6 @@ from xmodule.modulestore.edit_info import EditInfoRuntimeMixin
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError, DuplicateCourseError, ReferentialIntegrityError
|
||||
from xmodule.modulestore.inheritance import InheritanceMixin, inherit_metadata, InheritanceKeyValueStore
|
||||
from xmodule.modulestore.xml import CourseLocationManager
|
||||
from xmodule.modulestore.django import NullSignalHandler
|
||||
from xmodule.services import SettingsService
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -544,7 +543,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
|
||||
i18n_service=None,
|
||||
fs_service=None,
|
||||
user_service=None,
|
||||
signal_handler=NullSignalHandler(),
|
||||
signal_handler=None,
|
||||
retry_wait_time=0.1,
|
||||
**kwargs):
|
||||
"""
|
||||
|
||||
@@ -85,7 +85,6 @@ from xmodule.error_module import ErrorDescriptor
|
||||
from collections import defaultdict
|
||||
from types import NoneType
|
||||
from xmodule.assetstore import AssetMetadata
|
||||
from xmodule.modulestore.django import NullSignalHandler
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -641,8 +640,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
|
||||
default_class=None,
|
||||
error_tracker=null_error_tracker,
|
||||
i18n_service=None, fs_service=None, user_service=None,
|
||||
services=None, signal_handler=NullSignalHandler(),
|
||||
**kwargs):
|
||||
services=None, signal_handler=None, **kwargs):
|
||||
"""
|
||||
:param doc_store_config: must have a host, db, and collection entries. Other common entries: port, tz_aware.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user