Commit da26ae25 by Calen Pennington

Remove lms/lib from sys.path in favore of using it as the module lms.lib

parent bd5abc89
...@@ -16,7 +16,7 @@ from xmodule.modulestore.django import modulestore ...@@ -16,7 +16,7 @@ from xmodule.modulestore.django import modulestore
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
from xblock.runtime import DbModel from xblock.runtime import DbModel
from lms.xblock.field_data import LmsFieldData from lms.lib.xblock.field_data import LmsFieldData
from util.sandboxing import can_execute_unsafe_code from util.sandboxing import can_execute_unsafe_code
......
...@@ -28,7 +28,7 @@ import lms.envs.common ...@@ -28,7 +28,7 @@ import lms.envs.common
from lms.envs.common import USE_TZ, TECH_SUPPORT_EMAIL, PLATFORM_NAME, BUGS_EMAIL from lms.envs.common import USE_TZ, TECH_SUPPORT_EMAIL, PLATFORM_NAME, BUGS_EMAIL
from path import path from path import path
from lms.xblock.mixin import LmsBlockMixin from lms.lib.xblock.mixin import LmsBlockMixin
from cms.xmodule_namespace import CmsBlockMixin from cms.xmodule_namespace import CmsBlockMixin
from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.x_module import XModuleMixin from xmodule.x_module import XModuleMixin
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.contrib.auth.models import User from django.contrib.auth.models import User
import comment_client as cc import lms.lib.comment_client as cc
class Command(BaseCommand): class Command(BaseCommand):
......
...@@ -27,7 +27,7 @@ import django.dispatch ...@@ -27,7 +27,7 @@ import django.dispatch
from django.forms import ModelForm, forms from django.forms import ModelForm, forms
from course_modes.models import CourseMode from course_modes.models import CourseMode
import comment_client as cc import lms.lib.comment_client as cc
from pytz import UTC from pytz import UTC
import crum import crum
......
...@@ -82,7 +82,7 @@ def get_logger_config(log_dir, ...@@ -82,7 +82,7 @@ def get_logger_config(log_dir,
}, },
'newrelic': { 'newrelic': {
'level': 'ERROR', 'level': 'ERROR',
'class': 'newrelic_logging.NewRelicHandler', 'class': 'lms.lib.newrelic_logging.NewRelicHandler',
'formatter': 'raw', 'formatter': 'raw',
} }
}, },
......
...@@ -20,7 +20,7 @@ from capa.xqueue_interface import XQueueInterface ...@@ -20,7 +20,7 @@ from capa.xqueue_interface import XQueueInterface
from courseware.access import has_access from courseware.access import has_access
from courseware.masquerade import setup_masquerade from courseware.masquerade import setup_masquerade
from courseware.model_data import FieldDataCache, DjangoKeyValueStore from courseware.model_data import FieldDataCache, DjangoKeyValueStore
from lms.xblock.field_data import LmsFieldData from lms.lib.xblock.field_data import LmsFieldData
from mitxmako.shortcuts import render_to_string from mitxmako.shortcuts import render_to_string
from psychometrics.psychoanalyze import make_psychometrics_data_update_handler from psychometrics.psychoanalyze import make_psychometrics_data_update_handler
from student.models import unique_id_for_user from student.models import unique_id_for_user
......
...@@ -21,7 +21,7 @@ from xmodule.modulestore import Location ...@@ -21,7 +21,7 @@ from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from lms.xblock.field_data import LmsFieldData from lms.lib.xblock.field_data import LmsFieldData
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
......
...@@ -20,7 +20,7 @@ from courseware.tests.modulestore_config import TEST_DATA_DIR, \ ...@@ -20,7 +20,7 @@ from courseware.tests.modulestore_config import TEST_DATA_DIR, \
TEST_DATA_MONGO_MODULESTORE, \ TEST_DATA_MONGO_MODULESTORE, \
TEST_DATA_DRAFT_MONGO_MODULESTORE, \ TEST_DATA_DRAFT_MONGO_MODULESTORE, \
TEST_DATA_MIXED_MODULESTORE TEST_DATA_MIXED_MODULESTORE
from lms.xblock.field_data import LmsFieldData from lms.lib.xblock.field_data import LmsFieldData
class ActivateLoginTest(LoginEnrollmentTestCase): class ActivateLoginTest(LoginEnrollmentTestCase):
......
...@@ -18,7 +18,7 @@ log = logging.getLogger(__name__) ...@@ -18,7 +18,7 @@ log = logging.getLogger(__name__)
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
@patch('comment_client.utils.requests.request') @patch('lms.lib.comment_client.utils.requests.request')
class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase): class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase):
@patch.dict("django.conf.settings.MITX_FEATURES", {"ENABLE_DISCUSSION_SERVICE": True}) @patch.dict("django.conf.settings.MITX_FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
......
...@@ -6,7 +6,7 @@ import logging ...@@ -6,7 +6,7 @@ import logging
import urlparse import urlparse
import functools import functools
import comment_client as cc import lms.lib.comment_client as cc
import django_comment_client.utils as utils import django_comment_client.utils as utils
import django_comment_client.settings as cc_settings import django_comment_client.settings as cc_settings
...@@ -72,7 +72,7 @@ def create_thread(request, course_id, commentable_id): ...@@ -72,7 +72,7 @@ def create_thread(request, course_id, commentable_id):
""" """
Given a course and commentble ID, create the thread Given a course and commentble ID, create the thread
""" """
log.debug("Creating new thread in %r, id %r", course_id, commentable_id) log.debug("Creating new thread in %r, id %r", course_id, commentable_id)
course = get_course_with_access(request.user, course_id, 'load') course = get_course_with_access(request.user, course_id, 'load')
post = request.POST post = request.POST
......
...@@ -17,7 +17,7 @@ from courseware.access import has_access ...@@ -17,7 +17,7 @@ from courseware.access import has_access
from django_comment_client.permissions import cached_has_permission from django_comment_client.permissions import cached_has_permission
from django_comment_client.utils import (merge_dict, extract, strip_none, add_courseware_context) from django_comment_client.utils import (merge_dict, extract, strip_none, add_courseware_context)
import django_comment_client.utils as utils import django_comment_client.utils as utils
import comment_client as cc import lms.lib.comment_client as cc
THREADS_PER_PAGE = 20 THREADS_PER_PAGE = 20
INLINE_THREADS_PER_PAGE = 20 INLINE_THREADS_PER_PAGE = 20
......
...@@ -4,7 +4,7 @@ Reload forum (comment client) users from existing users. ...@@ -4,7 +4,7 @@ Reload forum (comment client) users from existing users.
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.contrib.auth.models import User from django.contrib.auth.models import User
import comment_client as cc import lms.lib.comment_client as cc
class Command(BaseCommand): class Command(BaseCommand):
......
from comment_client import CommentClientRequestError from lms.lib.comment_client import CommentClientRequestError
from django_comment_client.utils import JsonError from django_comment_client.utils import JsonError
import json import json
import logging import logging
......
...@@ -2,7 +2,7 @@ import django.http ...@@ -2,7 +2,7 @@ import django.http
from django.test import TestCase from django.test import TestCase
import json import json
import comment_client import lms.lib.comment_client
import django_comment_client.middleware as middleware import django_comment_client.middleware as middleware
...@@ -11,9 +11,9 @@ class AjaxExceptionTestCase(TestCase): ...@@ -11,9 +11,9 @@ class AjaxExceptionTestCase(TestCase):
self.a = middleware.AjaxExceptionMiddleware() self.a = middleware.AjaxExceptionMiddleware()
self.request1 = django.http.HttpRequest() self.request1 = django.http.HttpRequest()
self.request0 = django.http.HttpRequest() self.request0 = django.http.HttpRequest()
self.exception1 = comment_client.CommentClientRequestError('{}', 401) self.exception1 = lms.lib.comment_client.CommentClientRequestError('{}', 401)
self.exception2 = comment_client.CommentClientRequestError('Foo!', 404) self.exception2 = lms.lib.comment_client.CommentClientRequestError('Foo!', 404)
self.exception0 = comment_client.CommentClient500Error("Holy crap the server broke!") self.exception0 = lms.lib.comment_client.CommentClient500Error("Holy crap the server broke!")
self.request1.META['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest" self.request1.META['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"
self.request0.META['HTTP_X_REQUESTED_WITH'] = "SHADOWFAX" self.request0.META['HTTP_X_REQUESTED_WITH'] = "SHADOWFAX"
......
...@@ -4,7 +4,7 @@ from django.test import TestCase ...@@ -4,7 +4,7 @@ from django.test import TestCase
from django.test.utils import override_settings from django.test.utils import override_settings
from student.tests.factories import UserFactory, CourseEnrollmentFactory from student.tests.factories import UserFactory, CourseEnrollmentFactory
from django_comment_common.models import Role, Permission from django_comment_common.models import Role, Permission
from factories import RoleFactory from django_comment_client.tests.factories import RoleFactory
import django_comment_client.utils as utils import django_comment_client.utils as utils
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
......
...@@ -30,7 +30,7 @@ from path import path ...@@ -30,7 +30,7 @@ from path import path
from .discussionsettings import * from .discussionsettings import *
from lms.xblock.mixin import LmsBlockMixin from lms.lib.xblock.mixin import LmsBlockMixin
from xmodule.modulestore.inheritance import InheritanceMixin from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.x_module import XModuleMixin from xmodule.x_module import XModuleMixin
...@@ -213,9 +213,9 @@ COURSES_ROOT = ENV_ROOT / "data" ...@@ -213,9 +213,9 @@ COURSES_ROOT = ENV_ROOT / "data"
DATA_DIR = COURSES_ROOT DATA_DIR = COURSES_ROOT
# TODO: Remove the rest of the sys.path modification here and in cms/envs/common.py
sys.path.append(REPO_ROOT) sys.path.append(REPO_ROOT)
sys.path.append(PROJECT_ROOT / 'djangoapps') sys.path.append(PROJECT_ROOT / 'djangoapps')
sys.path.append(PROJECT_ROOT / 'lib')
sys.path.append(COMMON_ROOT / 'djangoapps') sys.path.append(COMMON_ROOT / 'djangoapps')
sys.path.append(COMMON_ROOT / 'lib') sys.path.append(COMMON_ROOT / 'lib')
...@@ -917,7 +917,7 @@ INSTALLED_APPS = ( ...@@ -917,7 +917,7 @@ INSTALLED_APPS = (
# Our courseware # Our courseware
'circuit', 'circuit',
'courseware', 'courseware',
'perfstats', 'lms.lib.perfstats',
'student', 'student',
'static_template_view', 'static_template_view',
'staticbook', 'staticbook',
......
...@@ -16,7 +16,7 @@ class LmsFieldData(SplitFieldData): ...@@ -16,7 +16,7 @@ class LmsFieldData(SplitFieldData):
def __init__(self, authored_data, student_data): def __init__(self, authored_data, student_data):
# Make sure that we don't repeatedly nest LmsFieldData instances # Make sure that we don't repeatedly nest LmsFieldData instances
if isinstance(authored_data, LmsFieldData): if isinstance(authored_data, LmsFieldData):
authored_data = authored_data._authored_data authored_data = authored_data._authored_data # pylint: disable=protected-member
else: else:
authored_data = ReadOnlyFieldData(authored_data) authored_data = ReadOnlyFieldData(authored_data)
......
...@@ -144,7 +144,7 @@ for key, value in settings.MKTG_URL_LINK_MAP.items(): ...@@ -144,7 +144,7 @@ for key, value in settings.MKTG_URL_LINK_MAP.items():
if settings.PERFSTATS: if settings.PERFSTATS:
urlpatterns += (url(r'^reprofile$', 'perfstats.views.end_profile'),) urlpatterns += (url(r'^reprofile$', 'lms.lib.perfstats.views.end_profile'),)
# Multicourse wiki (Note: wiki urls must be above the courseware ones because of # Multicourse wiki (Note: wiki urls must be above the courseware ones because of
# the custom tab catch-all) # the custom tab catch-all)
......
def run_pylint(system, report_dir, flags='') def run_pylint(system, report_dir, flags='')
apps = Dir["#{system}", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app| apps = Dir["#{system}", "#{system}/djangoapps/*"]
if system != 'lms'
apps += Dir["#{system}/lib/*"]
end
apps.map do |app|
File.basename(app) File.basename(app)
end.select do |app| end.select do |app|
app !=~ /.pyc$/ app !=~ /.pyc$/
......
...@@ -7,6 +7,10 @@ with-id=1 ...@@ -7,6 +7,10 @@ with-id=1
exclude-dir=lms/envs exclude-dir=lms/envs
cms/envs cms/envs
# Without this flag, nose adds /lib directories to the path,
# which shadows the xblock library (among other things)
no-path-adjustment=1
# Uncomment the following lines to open pdb when a test fails # Uncomment the following lines to open pdb when a test fails
#nocapture=1 #nocapture=1
#pdb=1 #pdb=1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment