openedx.core package#

Subpackages#

Submodules#

openedx.core.apidocs module#

Open API support.

openedx.core.apidocs.cursor_paginate_serializer(inner_serializer_class)#

Create a cursor-paginated version of a serializer.

This is hacky workaround for an edx-api-doc-tools issue described here: openedx/api-doc-tools#32

It assumes we are using cursor-style pagination and assumes a specific schema for the pages. It should be removed once we address the underlying issue.

Parameters:

inner_serializer_class (type) – A subclass of Serializer.

Returns: type

A subclass of Serializer to model the schema of a page of a cursor-paginated endpoint.

openedx.core.constants module#

Constants that are relevant to all of Open edX

openedx.core.process_warnings module#

openedx.core.pytest_hooks module#

Module to put all pytest hooks that modify pytest behaviour

class openedx.core.pytest_hooks.DeferPlugin#

Bases: object

Simple plugin to defer pytest-xdist hook functions.

pytest_json_modifyreport(json_report)#

standard xdist hook function.

pytest_sessionfinish(session)#
openedx.core.pytest_hooks.create_file_name(dir_path, file_name_postfix, num=0)#

Used to create file name with this given structure: TEST_SUITE + “_” + file_name_postfix + “_ “ + num.json The env variable TEST_SUITE is set in jenkinsfile

This was necessary cause Pytest is run multiple times and we need to make sure old pytest warning json files are not being overwritten.

openedx.core.pytest_hooks.pytest_configure(config)#
openedx.core.pytest_hooks.pytest_json_modifyreport(json_report)#
  • The function is called by pytest-json-report plugin to only output warnings in json format.

  • Everything else is removed due to it already being saved by junitxml

  • –json-omit flag in does not allow us to remove everything but the warnings

  • (the environment metadata is one example of unremoveable data)

  • The json warning outputs are meant to be read by jenkins

openedx.core.pytest_hooks.pytest_sessionfinish(session)#

Since multiple pytests are running, this makes sure warnings from different run are not overwritten

openedx.core.release module#

Information about the release line of this Open edX code.

openedx.core.release.doc_version()#

The readthedocs.org version name used in documentation references.

Returns a short string like “latest” or “open-release-ficus.master”.

openedx.core.release.skip_unless_master(func_or_class)#

Only run the decorated test for code on master or destined for master.

Use this to skip tests that we expect to fail on a named release branch. Please use carefully!

openedx.core.storage module#

Django storage backends for Open edX.

class openedx.core.storage.DevelopmentStorage(*args, **kwargs)#

Bases: NonPackagingMixin, ThemePipelineMixin, ThemeMixin, StaticFilesStorage

This class combines Django’s StaticFilesStorage class with several mixins that provide additional functionality. We use this version for development, so that we can skip packaging and optimization.

class openedx.core.storage.OverwriteStorage(*args, **kwargs)#

Bases: FileSystemStorage

FileSystemStorage subclass which automatically overwrites any previous file with the same name; used in test runs to avoid test file proliferation. Copied from django-storages when this class was removed in version 1.6.

Comes from http://www.djangosnippets.org/snippets/976/ (even if it already exists in S3Storage for ages) See also Django #4339, which might add this functionality to core.

deconstruct()#

Return a 3-tuple of class import path, positional arguments, and keyword arguments.

get_available_name(name, max_length=None)#

Returns a filename that’s free on the target storage system, and available for new content to be written to.

class openedx.core.storage.PipelineForgivingMixin#

Bases: object

An extension of the django-pipeline storage backend which forgives missing files.

hashed_name(name, content=None, **kwargs)#
stored_name(name)#
class openedx.core.storage.ProductionMixin(*args, **kwargs)#

Bases: PipelineForgivingMixin, OptimizedFilesMixin, ThemePipelineMixin, ThemeManifestFilesMixin, ThemeMixin

This class combines several mixins that provide additional functionality, and can be applied over an existing Storage. We use this version on production.

class openedx.core.storage.ProductionS3Storage(*args, **kwargs)#

Bases: ProductionMixin, S3Storage

class openedx.core.storage.ProductionStorage(*args, **kwargs)#

Bases: ProductionMixin, StaticFilesStorage

openedx.core.storage.get_storage(storage_class=None, **kwargs)#

Returns a storage instance with the given class name and kwargs. If the class name is not given, an instance of the default storage is returned. Instances are cached so that if this function is called multiple times with the same arguments, the same instance is returned. This is useful if the storage implementation makes http requests when instantiated, for example.

openedx.core.toggles module#

Feature toggles used across the platform. Toggles should only be added to this module if we don’t have a better place for them. Generally speaking, they should be added to the most appropriate app or repo.

openedx.core.toggles.enable_authz_course_authoring(course_key)#

Returns a boolean if the AuthZ for course authoring feature is enabled for the given course.

openedx.core.write_to_html module#

Class used to write pytest warning data into html format

class openedx.core.write_to_html.HtmlOutlineWriter(fout)#

Bases: object

writer to handle html writing

HEAD = '\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset="utf-8" />\n</head>\n<style>\n.toggle-box{\ndisplay:none;\n}\n.toggle-box + label + div {\n    display: none;\n}\n.toggle-box + label:before {\n    color: #888;\n    width: 10px;\n}\n\n.toggle-box:checked + label + div {\n    margin-left: 3%;\n    display: flex;\n    flex-direction: column;\n}\ndiv{\nborder-style: solid;\n    border-width: 1px 0px 0px 0px;\n    border-radius: 3px;\n}\n\n.location {\nbackground-color: #edcca9\n}\n\nbody {\nbackground-color: cornsilk\n}\n\n.warning_text {\nbackground-color: #d5b593\n}\n.warning{\nbackground-color: #bd9f7d\n}\n.num {\nbackground-color: #a68968;\n}\n.lineno {\nbackground-color: #a68968;\n}\n\n\n}\n\n\n</style>\n<body>\n'#
SECTION_END = '</div></div>'#
SECTION_START = '<div class="{klass}">\n<input class="toggle-box {klass}" id="sect_{id:05d}" type="checkbox">\n<label for="sect_{id:05d}">{html}</label>\n<div>\n'#
end_section()#
start_section(html, klass=None)#
write(html)#

Module contents#

This is the root package for all core Open edX functionality. In particular, the djangoapps subpackage is the location for all Django apps that are shared between LMS and CMS.

Note: the majority of the core functionality currently lives in the root common directory. All new Django apps should be created here instead, and the pre-existing apps will be moved here over time.