Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS * Generate common/djangoapps import shims for Studio * Stop appending project root to sys.path * Stop appending common/djangoapps to sys.path * Import from common.djangoapps.course_action_state instead of course_action_state * Import from common.djangoapps.course_modes instead of course_modes * Import from common.djangoapps.database_fixups instead of database_fixups * Import from common.djangoapps.edxmako instead of edxmako * Import from common.djangoapps.entitlements instead of entitlements * Import from common.djangoapps.pipline_mako instead of pipeline_mako * Import from common.djangoapps.static_replace instead of static_replace * Import from common.djangoapps.student instead of student * Import from common.djangoapps.terrain instead of terrain * Import from common.djangoapps.third_party_auth instead of third_party_auth * Import from common.djangoapps.track instead of track * Import from common.djangoapps.util instead of util * Import from common.djangoapps.xblock_django instead of xblock_django * Add empty common/djangoapps/__init__.py to fix pytest collection * Fix pylint formatting violations * Exclude import_shims/ directory tree from linting
This commit is contained in:
@@ -447,12 +447,10 @@ COURSES_ROOT = ENV_ROOT / "data"
|
||||
|
||||
GITHUB_REPO_ROOT = ENV_ROOT / "data"
|
||||
|
||||
# TODO: Is this next line necessary?
|
||||
sys.path.append(REPO_ROOT)
|
||||
# TODO: The next two path modifications will be removed in an upcoming Open edX release.
|
||||
# TODO: This path modification exists as temporary support for deprecated import patterns.
|
||||
# It will be removed in an upcoming Open edX release.
|
||||
# See docs/decisions/0007-sys-path-modification-removal.rst
|
||||
sys.path.append(REPO_ROOT / 'import_shims' / 'studio')
|
||||
sys.path.append(COMMON_ROOT / 'djangoapps')
|
||||
|
||||
# For geolocation ip database
|
||||
GEOIP_PATH = REPO_ROOT / "common/static/data/geoip/GeoLite2-Country.mmdb"
|
||||
@@ -511,8 +509,8 @@ TEMPLATES = [
|
||||
# We have to use mako-aware template loaders to be able to include
|
||||
# mako templates inside django templates (such as main_django.html).
|
||||
'openedx.core.djangoapps.theming.template_loaders.ThemeTemplateLoader',
|
||||
'edxmako.makoloader.MakoFilesystemLoader',
|
||||
'edxmako.makoloader.MakoAppDirectoriesLoader',
|
||||
'common.djangoapps.edxmako.makoloader.MakoFilesystemLoader',
|
||||
'common.djangoapps.edxmako.makoloader.MakoAppDirectoriesLoader',
|
||||
),
|
||||
'context_processors': CONTEXT_PROCESSORS,
|
||||
# Change 'debug' in your environment settings files - not here.
|
||||
@@ -521,7 +519,7 @@ TEMPLATES = [
|
||||
},
|
||||
{
|
||||
'NAME': 'mako',
|
||||
'BACKEND': 'edxmako.backend.Mako',
|
||||
'BACKEND': 'common.djangoapps.edxmako.backend.Mako',
|
||||
'APP_DIRS': False,
|
||||
'DIRS': _make_mako_template_dirs,
|
||||
'OPTIONS': {
|
||||
@@ -532,7 +530,7 @@ TEMPLATES = [
|
||||
{
|
||||
# This separate copy of the Mako backend is used to render previews using the LMS templates
|
||||
'NAME': 'preview',
|
||||
'BACKEND': 'edxmako.backend.Mako',
|
||||
'BACKEND': 'common.djangoapps.edxmako.backend.Mako',
|
||||
'APP_DIRS': False,
|
||||
'DIRS': lms.envs.common.MAKO_TEMPLATE_DIRS_BASE,
|
||||
'OPTIONS': {
|
||||
@@ -691,11 +689,11 @@ MIDDLEWARE = [
|
||||
# Instead of AuthenticationMiddleware, we use a cache-backed version
|
||||
'openedx.core.djangoapps.cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
|
||||
|
||||
'student.middleware.UserStandingMiddleware',
|
||||
'common.djangoapps.student.middleware.UserStandingMiddleware',
|
||||
'openedx.core.djangoapps.contentserver.middleware.StaticContentServer',
|
||||
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'track.middleware.TrackMiddleware',
|
||||
'common.djangoapps.track.middleware.TrackMiddleware',
|
||||
|
||||
# This is used to set or update the user language preferences.
|
||||
'openedx.core.djangoapps.lang_pref.middleware.LanguagePreferenceMiddleware',
|
||||
@@ -833,7 +831,7 @@ MODULESTORE = {
|
||||
'OPTIONS': {
|
||||
'default_class': 'xmodule.hidden_module.HiddenDescriptor',
|
||||
'fs_root': DATA_DIR,
|
||||
'render_template': 'edxmako.shortcuts.render_to_string',
|
||||
'render_template': 'common.djangoapps.edxmako.shortcuts.render_to_string',
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -843,7 +841,7 @@ MODULESTORE = {
|
||||
'OPTIONS': {
|
||||
'default_class': 'xmodule.hidden_module.HiddenDescriptor',
|
||||
'fs_root': DATA_DIR,
|
||||
'render_template': 'edxmako.shortcuts.render_to_string',
|
||||
'render_template': 'common.djangoapps.edxmako.shortcuts.render_to_string',
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1347,7 +1345,7 @@ INSTALLED_APPS = [
|
||||
|
||||
'openedx.core.djangoapps.contentserver',
|
||||
'cms.djangoapps.course_creators',
|
||||
'student.apps.StudentConfig', # misleading name due to sharing with lms
|
||||
'common.djangoapps.student.apps.StudentConfig', # misleading name due to sharing with lms
|
||||
'openedx.core.djangoapps.course_groups', # not used in cms (yet), but tests run
|
||||
'cms.djangoapps.xblock_config.apps.XBlockConfig',
|
||||
|
||||
@@ -1359,13 +1357,13 @@ INSTALLED_APPS = [
|
||||
'openedx.core.djangoapps.util.apps.UtilConfig',
|
||||
|
||||
# Tracking
|
||||
'track',
|
||||
'common.djangoapps.track',
|
||||
'eventtracking.django.apps.EventTrackingConfig',
|
||||
|
||||
# For asset pipelining
|
||||
'edxmako.apps.EdxMakoConfig',
|
||||
'common.djangoapps.edxmako.apps.EdxMakoConfig',
|
||||
'pipeline',
|
||||
'static_replace',
|
||||
'common.djangoapps.static_replace',
|
||||
'require',
|
||||
'webpack_loader',
|
||||
|
||||
@@ -1382,7 +1380,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
|
||||
# for managing course modes
|
||||
'course_modes.apps.CourseModesConfig',
|
||||
'common.djangoapps.course_modes.apps.CourseModesConfig',
|
||||
|
||||
# Verified Track Content Cohorting (Beta feature that will hopefully be removed)
|
||||
'openedx.core.djangoapps.verified_track_content',
|
||||
@@ -1403,7 +1401,7 @@ INSTALLED_APPS = [
|
||||
'openedx.core.djangoapps.embargo',
|
||||
|
||||
# Course action state
|
||||
'course_action_state',
|
||||
'common.djangoapps.course_action_state',
|
||||
|
||||
# Additional problem types
|
||||
'edx_jsme', # Molecular Structure
|
||||
@@ -1423,7 +1421,7 @@ INSTALLED_APPS = [
|
||||
# Credit courses
|
||||
'openedx.core.djangoapps.credit.apps.CreditConfig',
|
||||
|
||||
'xblock_django',
|
||||
'common.djangoapps.xblock_django',
|
||||
|
||||
# Catalog integration
|
||||
'openedx.core.djangoapps.catalog',
|
||||
@@ -1470,7 +1468,7 @@ INSTALLED_APPS = [
|
||||
'cms.djangoapps.cms_user_tasks.apps.CmsUserTasksConfig',
|
||||
|
||||
# Unusual migrations
|
||||
'database_fixups',
|
||||
'common.djangoapps.database_fixups',
|
||||
|
||||
# Customized celery tasks, including persisting failed tasks so they can
|
||||
# be retried
|
||||
@@ -1487,10 +1485,10 @@ INSTALLED_APPS = [
|
||||
'csrf.apps.CsrfAppConfig', # Enables frontend apps to retrieve CSRF tokens.
|
||||
|
||||
# Entitlements, used in openedx tests
|
||||
'entitlements',
|
||||
'common.djangoapps.entitlements',
|
||||
|
||||
# Asset management for mako templates
|
||||
'pipeline_mako',
|
||||
'common.djangoapps.pipeline_mako',
|
||||
|
||||
# API Documentation
|
||||
'drf_yasg',
|
||||
@@ -1542,7 +1540,7 @@ TRACK_MAX_EVENT = 50000
|
||||
|
||||
TRACKING_BACKENDS = {
|
||||
'logger': {
|
||||
'ENGINE': 'track.backends.logger.LoggerBackend',
|
||||
'ENGINE': 'common.djangoapps.track.backends.logger.LoggerBackend',
|
||||
'OPTIONS': {
|
||||
'name': 'tracking'
|
||||
}
|
||||
@@ -1568,8 +1566,8 @@ EVENT_TRACKING_BACKENDS = {
|
||||
}
|
||||
},
|
||||
'processors': [
|
||||
{'ENGINE': 'track.shim.LegacyFieldMappingProcessor'},
|
||||
{'ENGINE': 'track.shim.PrefixedEventProcessor'}
|
||||
{'ENGINE': 'common.djangoapps.track.shim.LegacyFieldMappingProcessor'},
|
||||
{'ENGINE': 'common.djangoapps.track.shim.PrefixedEventProcessor'}
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -1587,7 +1585,7 @@ EVENT_TRACKING_BACKENDS = {
|
||||
}
|
||||
},
|
||||
{
|
||||
'ENGINE': 'track.shim.GoogleAnalyticsProcessor'
|
||||
'ENGINE': 'common.djangoapps.track.shim.GoogleAnalyticsProcessor'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1603,13 +1601,13 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||
},
|
||||
{
|
||||
"NAME": "util.password_policy_validators.MinimumLengthValidator",
|
||||
"NAME": "common.djangoapps.util.password_policy_validators.MinimumLengthValidator",
|
||||
"OPTIONS": {
|
||||
"min_length": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"NAME": "util.password_policy_validators.MaximumLengthValidator",
|
||||
"NAME": "common.djangoapps.util.password_policy_validators.MaximumLengthValidator",
|
||||
"OPTIONS": {
|
||||
"max_length": 75
|
||||
}
|
||||
@@ -1858,53 +1856,53 @@ DATABASE_ROUTERS = [
|
||||
CACHES = {
|
||||
'blockstore': {
|
||||
'KEY_PREFIX': 'blockstore',
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'TIMEOUT': '86400', # This data should be long-lived for performance, BundleCache handles invalidation
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'course_structure_cache': {
|
||||
'KEY_PREFIX': 'course_structure',
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'TIMEOUT': '7200',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'celery': {
|
||||
'KEY_PREFIX': 'celery',
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'TIMEOUT': '7200',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'mongo_metadata_inheritance': {
|
||||
'KEY_PREFIX': 'mongo_metadata_inheritance',
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'TIMEOUT': 300,
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'staticfiles': {
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'KEY_PREFIX': 'staticfiles_general',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'default': {
|
||||
'VERSION': '1',
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'KEY_PREFIX': 'default',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'configuration': {
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'KEY_PREFIX': 'configuration',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
},
|
||||
'general': {
|
||||
'KEY_FUNCTION': 'util.memcache.safe_key',
|
||||
'KEY_FUNCTION': 'common.djangoapps.util.memcache.safe_key',
|
||||
'LOCATION': ['localhost:11211'],
|
||||
'KEY_PREFIX': 'general',
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
|
||||
Reference in New Issue
Block a user