def METHOD_NAME(self, cache_path):
    """ Add a path to this cache context. Also creates necessary
        sub-directories.
    """
    self._cached_objects.add(cache_path)
    relative_path = self.relative_path(cache_path)
    try:
        # create all necessary subdirectories
        os.makedirs(os.path.dirname(relative_path))
    except OSError as e:
        # it's only ok if the dir already existed
        if e.errno != errno.EEXIST:
            raise
    return relative_path