diff --git a/cms/djangoapps/auth/authz.py b/cms/djangoapps/auth/authz.py index c6a67bd451c4b70d88197560f6778fddcc3539b9..19c00f832ac41dcc63ff62effb1ea100f66384b9 100644 --- a/cms/djangoapps/auth/authz.py +++ b/cms/djangoapps/auth/authz.py @@ -203,8 +203,7 @@ def remove_user_from_course_group(caller, user, location, role): # see if the user is actually in that role, if not then we don't have to do anything groupnames, _ = get_all_course_role_groupnames(location, role) - for group in user.groups.filter(name__in=groupnames): - user.groups.remove(group) + user.groups.remove(*user.groups.filter(name__in=groupnames)) user.save() diff --git a/cms/envs/dev.py b/cms/envs/dev.py index 74561cee636f5a221b8f3d187cad0a27ca205659..0ca4266f40d256871e27073670d0b32e020ae703 100644 --- a/cms/envs/dev.py +++ b/cms/envs/dev.py @@ -129,7 +129,12 @@ CACHES = { 'LOCATION': '/var/tmp/mongo_metadata_inheritance', 'TIMEOUT': 300, 'KEY_FUNCTION': 'util.memcache.safe_key', - } + }, + 'loc_cache': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'edx_location_mem_cache', + }, + } # Make the keyedcache startup warnings go away diff --git a/cms/envs/test.py b/cms/envs/test.py index a35824ed52be5b464d924cff5ec3904d2fcadd38..e541b0d390dc95942f1c4b6a8916090269a5cdb9 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -138,7 +138,12 @@ CACHES = { 'LOCATION': '/var/tmp/mongo_metadata_inheritance', 'TIMEOUT': 300, 'KEY_FUNCTION': 'util.memcache.safe_key', - } + }, + 'loc_cache': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'edx_location_mem_cache', + }, + } # hide ratelimit warnings while running tests diff --git a/common/lib/xmodule/xmodule/modulestore/django.py b/common/lib/xmodule/xmodule/modulestore/django.py index a17886c484748d3b1dcbf789aef9c3a4e09c52e8..ef4b9df40afc0846dcd25de78c56c8089cd167f2 100644 --- a/common/lib/xmodule/xmodule/modulestore/django.py +++ b/common/lib/xmodule/xmodule/modulestore/django.py @@ -129,8 +129,12 @@ def loc_mapper(): global _loc_singleton # pylint: disable=W0212 if _loc_singleton is None: + try: + loc_cache = get_cache('loc_cache') + except InvalidCacheBackendError: + loc_cache = get_cache('default') # instantiate - _loc_singleton = LocMapperStore(get_cache('default'), **settings.DOC_STORE_CONFIG) + _loc_singleton = LocMapperStore(loc_cache, **settings.DOC_STORE_CONFIG) # inject into split mongo modulestore if 'split' in _MODULESTORES: _MODULESTORES['split'].loc_mapper = _loc_singleton diff --git a/lms/envs/dev.py b/lms/envs/dev.py index bfff68157e1b5da109060ac886f212bff01c7de0..30053d3da3e50b95ca9ebd01b1dd0fe0bcd516da 100644 --- a/lms/envs/dev.py +++ b/lms/envs/dev.py @@ -85,7 +85,11 @@ CACHES = { 'LOCATION': '/var/tmp/mongo_metadata_inheritance', 'TIMEOUT': 300, 'KEY_FUNCTION': 'util.memcache.safe_key', - } + }, + 'loc_cache': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'edx_location_mem_cache', + }, } diff --git a/lms/envs/test.py b/lms/envs/test.py index 31636f6aad95c81be8ed0f65f93192119716ddec..52b5b74c90f1cd2ef7d89a2736b9980c8ca89454 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -165,7 +165,12 @@ CACHES = { 'LOCATION': '/var/tmp/mongo_metadata_inheritance', 'TIMEOUT': 300, 'KEY_FUNCTION': 'util.memcache.safe_key', - } + }, + 'loc_cache': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + 'LOCATION': 'edx_location_mem_cache', + }, + } # Dummy secret key for dev