'Returns a fully-qualified path to a piece of static content.
If a static asset CDN is configured, this path will include it.
Otherwise, the path will simply be relative.
Args:
course_key: key to the course which owns this asset
path: the path to said content
Returns:
string: fully-qualified path to asset'

@staticmethod
def get_canonicalized_asset_path(course_key, path, base_url, excluded_exts, encode=True):

    (_, _, relative_path, params, query_string, _) = urlparse(path)
    asset_key = StaticContent.get_asset_key_from_path(course_key, relative_path)
    serve_from_cdn = False
    content_digest = None
    try:
        content = AssetManager.find(asset_key, as_stream=True)
        serve_from_cdn = (not getattr(content, 'locked', True))
        content_digest = getattr(content, 'content_digest', None)
    except (ItemNotFoundError, NotFoundError):
        serve_from_cdn = False
    is_excluded = False
    if StaticContent.is_excluded_asset_type(relative_path, excluded_exts):
        serve_from_cdn = False
        is_excluded = True
    query_params = parse_qsl(query_string)
    updated_query_params = []
    for (query_name, query_val) in query_params:
        if query_val.startswith('/static/'):
            new_val = StaticContent.get_canonicalized_asset_path(course_key, query_val, base_url, excluded_exts, encode=False)
            updated_query_params.append((query_name, new_val))
        else:
            updated_query_params.append((query_name, query_val.encode('utf-8')))
    serialized_asset_key = StaticContent.serialize_asset_key_with_slash(asset_key)
    base_url = (base_url if serve_from_cdn else '')
    asset_path = serialized_asset_key
    if ((not is_excluded) and content_digest):
        asset_path = StaticContent.add_version_to_asset_path(serialized_asset_key, content_digest)
    asset_path = asset_path.encode('utf-8')
    if encode:
        asset_path = quote_plus(asset_path, '/:+@')
    return urlunparse((None, base_url.encode('utf-8'), asset_path, params, urlencode(updated_query_params), None))
