'Get slug from URLs requesting docs.
If URL is like \'/docs/<project_name>/\', we split path
and pull out slug.
If URL is subdomain or CNAME, we simply read request.slug, which is
set by SubdomainMiddleware.'

def _get_slug(self, request):

    slug = None
    if hasattr(request, 'slug'):
        slug = request.slug.lower()
    else:
        path = request.get_full_path()
        path_parts = path.split('/')
        if ((len(path_parts) > 2) and (path_parts[1] == 'docs')):
            slug = path_parts[2].lower()
    return slug
