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.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.

openedx.core.djangoapps.contentserver.urls module#

URL patterns for course asset serving.

openedx.core.djangoapps.contentserver.views module#

Views for serving course assets.

For historical reasons, this is just one view that matches to three different URL patterns, and then has to re-parse the URL to determine which pattern is in effect. We should probably have 3 views as entry points.

openedx.core.djangoapps.contentserver.views.course_assets_view(request)#

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

openedx.core.djangoapps.contentserver.views.get_expiration_value(now, cache_ttl)#

Generates an RFC1123 datetime string based on a future offset.

openedx.core.djangoapps.contentserver.views.is_asset_request(request)#

Determines whether the given request is an asset request

openedx.core.djangoapps.contentserver.views.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.

openedx.core.djangoapps.contentserver.views.is_content_locked(content)#

Determines whether or not the given content is locked.

openedx.core.djangoapps.contentserver.views.is_user_authorized(request, content, location)#

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

Any asset classes that have restrictions placed on them should also be marked as no-cache in set_caching_headers.

openedx.core.djangoapps.contentserver.views.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.

openedx.core.djangoapps.contentserver.views.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.views.process_request(request)#

Process the given request

openedx.core.djangoapps.contentserver.views.set_caching_headers(content, location, response)#

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

Module contents#

Serves course assets to end users.