openedx.core.djangoapps.contentserver package#

Submodules#

openedx.core.djangoapps.contentserver.caching module#

Helper functions for caching course assets.

openedx.core.djangoapps.contentserver.caching.del_cached_content(location)#

Delete content for the given location, as well versions of the content without a run.

It’s possible that the content could have been cached without knowing the course_key, and so without having the run.

openedx.core.djangoapps.contentserver.caching.get_cached_content(location)#

Retrieves the given piece of content by its location if cached.

openedx.core.djangoapps.contentserver.caching.set_cached_content(content)#

Stores the given piece of content in the cache, using its location as the key.

openedx.core.djangoapps.contentserver.middleware module#

Middleware to serve assets.

class openedx.core.djangoapps.contentserver.middleware.StaticContentServer(get_response)#

Bases: MiddlewareMixin

Serves course assets to end users. Colloquially referred to as “contentserver.”

static get_expiration_value(now, cache_ttl)#

Generates an RFC1123 datetime string based on a future offset.

is_asset_request(request)#

Determines whether the given request is an asset request

static is_cdn_request(request)#

Attempts to determine whether or not the given request is coming from a CDN.

Currently, this is a static check because edx.org only uses CloudFront, but may be expanded in the future.

is_content_locked(content)#

Determines whether or not the given content is locked.

is_user_authorized(request, content, location)#

Determines whether or not the user for this request is authorized to view the given asset.

load_asset_from_location(location)#

Loads an asset based on its location, either retrieving it from a cache or loading it directly from the contentstore.

process_request(request)#

Process the given request

set_caching_headers(content, response)#

Sets caching headers based on whether or not the asset is locked.

openedx.core.djangoapps.contentserver.middleware.parse_range_header(header_value, content_length)#

Returns the unit and a list of (start, end) tuples of ranges.

Raises ValueError if header is syntactically invalid or does not contain a range.

See spec for details: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35

openedx.core.djangoapps.contentserver.models module#

Models for contentserver

class openedx.core.djangoapps.contentserver.models.CdnUserAgentsConfig(*args, **kwargs)#

Bases: ConfigurationModel

Configuration for the user agents we expect to see from CDNs.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

cdn_user_agents#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

change_date#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

changed_by#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

changed_by_id#
enabled#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod get_cdn_user_agents()#

Gets the list of CDN user agents, if present

get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class openedx.core.djangoapps.contentserver.models.CourseAssetCacheTtlConfig(*args, **kwargs)#

Bases: ConfigurationModel

Configuration for the TTL of course assets.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

cache_ttl#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

change_date#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

changed_by#

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

changed_by_id#
enabled#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod get_cache_ttl()#

Gets the cache TTL for course assets, if present

get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

Module contents#

Serves course assets to end users.