'Handle DELETE requests when in stack mode.
Delete current version of object and pop previous version in its place.
:param req: original request.
:param versions_cont: container where previous versions of the object
are stored.
:param api_version: api version.
:param account_name: account name.
:param container_name: container name.
:param object_name: object name.'

def handle_obj_versions_delete_pop(self, req, versions_cont, api_version, account_name, container_name, object_name):

    listing_prefix = self._build_versions_object_prefix(object_name)
    item_iter = self._listing_iter(account_name, versions_cont, listing_prefix, req)
    auth_token_header = {'X-Auth-Token': req.headers.get('X-Auth-Token')}
    authed = False
    for previous_version in item_iter:
        if (not authed):
            if ('swift.authorize' in req.environ):
                container_info = get_container_info(req.environ, self.app)
                req.acl = container_info.get('write_acl')
                aresp = req.environ['swift.authorize'](req)
                if aresp:
                    return aresp
                authed = True
        if (previous_version['content_type'] == DELETE_MARKER_CONTENT_TYPE):
            obj_head_headers = {'X-Newest': 'True'}
            obj_head_headers.update(auth_token_header)
            head_req = make_pre_authed_request(req.environ, path=req.path_info, method='HEAD', headers=obj_head_headers, swift_source='VW')
            hresp = head_req.get_response(self.app)
            close_if_possible(hresp.app_iter)
            if (hresp.status_int != HTTP_NOT_FOUND):
                self._check_response_error(req, hresp)
                break
            for version_to_restore in item_iter:
                if (version_to_restore['content_type'] == DELETE_MARKER_CONTENT_TYPE):
                    break
                prev_obj_name = version_to_restore['name'].encode('utf-8')
                restored_path = self._restore_data(req, versions_cont, api_version, account_name, container_name, object_name, prev_obj_name)
                if (not restored_path):
                    continue
                old_del_req = make_pre_authed_request(req.environ, path=restored_path, method='DELETE', headers=auth_token_header, swift_source='VW')
                del_resp = old_del_req.get_response(self.app)
                close_if_possible(del_resp.app_iter)
                if (del_resp.status_int != HTTP_NOT_FOUND):
                    self._check_response_error(req, del_resp)
                break
            marker_path = ('/%s/%s/%s/%s' % (api_version, account_name, versions_cont, previous_version['name'].encode('utf-8')))
            req = make_pre_authed_request(req.environ, path=marker_path, method='DELETE', headers=auth_token_header, swift_source='VW')
        else:
            prev_obj_name = previous_version['name'].encode('utf-8')
            restored_path = self._restore_data(req, versions_cont, api_version, account_name, container_name, object_name, prev_obj_name)
            if (not restored_path):
                continue
            req = make_pre_authed_request(req.environ, path=restored_path, method='DELETE', headers=auth_token_header, swift_source='VW')
        if ('X-If-Delete-At' in req.headers):
            del req.headers['X-If-Delete-At']
        break
    return req.get_response(self.app)
