'Checks if the container exists and if not try to create it.
:params container_path: an unquoted path to a container to be created
:returns: True if created container, False if container exists
:raises CreateContainerError: when unable to create container'

def create_container(self, req, container_path):

    new_env = req.environ.copy()
    new_env['PATH_INFO'] = container_path
    new_env['swift.source'] = 'EA'
    new_env['REQUEST_METHOD'] = 'HEAD'
    head_cont_req = Request.blank(container_path, environ=new_env)
    resp = head_cont_req.get_response(self.app)
    if resp.is_success:
        return False
    if (resp.status_int == 404):
        new_env = req.environ.copy()
        new_env['PATH_INFO'] = container_path
        new_env['swift.source'] = 'EA'
        new_env['REQUEST_METHOD'] = 'PUT'
        create_cont_req = Request.blank(container_path, environ=new_env)
        resp = create_cont_req.get_response(self.app)
        if resp.is_success:
            return True
    raise CreateContainerError(('Create    Container    Failed:    ' + container_path), resp.status_int, resp.status)
