def _convert_response_to_entity(response):
    if response is None:
        return response

    root = ETree.fromstring(response.body)

    return _convert_etree_element_to_entity(root)
Exemple #2
0
def _convert_response_to_entity(response):
    if response is None:
        return response

    root = ETree.fromstring(response.body)

    return _convert_etree_element_to_entity(root)
    def _report_batch_error(self, response):
        doc = ETree.fromstring(response.body)

        code_element = doc.find('./m:code', _etree_entity_feed_namespaces)
        code = _get_etree_text(code_element) if code_element is not None else ''

        message_element = doc.find('./m:message', _etree_entity_feed_namespaces)
        message = _get_etree_text(message_element) if message_element is not None else ''

        raise WindowsAzureBatchOperationError(message, code)
def _convert_response_to_block_list(response):
    '''
    Converts xml response to block list class.
    '''
    block_list = BlobBlockList()

    list_element = ETree.fromstring(response.body)

    for block_element in list_element.findall('./CommittedBlocks/Block'):
        block = _convert_block_etree_element_to_blob_block(block_element)
        block_list.committed_blocks.append(block)

    for block_element in list_element.findall('./UncommittedBlocks/Block'):
        block = _convert_block_etree_element_to_blob_block(block_element)
        block_list.uncommitted_blocks.append(block)

    return block_list
Exemple #5
0
def _convert_response_to_block_list(response):
    '''
    Converts xml response to block list class.
    '''
    block_list = BlobBlockList()

    list_element = ETree.fromstring(response.body)

    for block_element in list_element.findall('./CommittedBlocks/Block'):
        block = _convert_block_etree_element_to_blob_block(block_element)
        block_list.committed_blocks.append(block)

    for block_element in list_element.findall('./UncommittedBlocks/Block'):
        block = _convert_block_etree_element_to_blob_block(block_element)
        block_list.uncommitted_blocks.append(block)

    return block_list
def _parse_blob_enum_results_list(response):
    respbody = response.body
    return_obj = BlobEnumResults()
    enum_results = ETree.fromstring(respbody)

    for child in enum_results.findall('./Blobs/Blob'):
        return_obj.blobs.append(_ETreeXmlToObject.fill_instance_element(child, Blob))

    for child in enum_results.findall('./Blobs/BlobPrefix'):
        return_obj.prefixes.append(
            _ETreeXmlToObject.fill_instance_element(child, BlobPrefix))

    for name, value in vars(return_obj).items():
        if name == 'blobs' or name == 'prefixes':
            continue
        value = _ETreeXmlToObject.fill_data_member(enum_results, name, value)
        if value is not None:
            setattr(return_obj, name, value)

    return return_obj
Exemple #7
0
def _parse_blob_enum_results_list(response):
    respbody = response.body
    return_obj = BlobEnumResults()
    enum_results = ETree.fromstring(respbody)

    for child in enum_results.findall('./Blobs/Blob'):
        return_obj.blobs.append(_ETreeXmlToObject.fill_instance_element(child, Blob))

    for child in enum_results.findall('./Blobs/BlobPrefix'):
        return_obj.prefixes.append(
            _ETreeXmlToObject.fill_instance_element(child, BlobPrefix))

    for name, value in vars(return_obj).items():
        if name == 'blobs' or name == 'prefixes':
            continue
        value = _ETreeXmlToObject.fill_data_member(enum_results, name, value)
        if value is not None:
            setattr(return_obj, name, value)

    return return_obj
    def get_request_partition_key(self, request):
        '''
        Extracts PartitionKey from request.body if it is a POST request or from
        request.path if it is not a POST request. Only insert operation request
        is a POST request and the PartitionKey is in the request body.

        request:
            the request to insert, update or delete entity
        '''
        if request.method == 'POST':
            doc = ETree.fromstring(request.body)
            part_key = doc.find('./atom:content/m:properties/d:PartitionKey', _etree_entity_feed_namespaces)
            if part_key is None:
                raise WindowsAzureError(_ERROR_CANNOT_FIND_PARTITION_KEY)
            return _get_etree_text(part_key)
        else:
            uri = url_unquote(request.path)
            pos1 = uri.find('PartitionKey=\'')
            pos2 = uri.find('\',', pos1)
            if pos1 == -1 or pos2 == -1:
                raise WindowsAzureError(_ERROR_CANNOT_FIND_PARTITION_KEY)
            return uri[pos1 + len('PartitionKey=\''):pos2]
Exemple #9
0
def _convert_response_to_subscription(response):
    root = ETree.fromstring(response.body)
    return _convert_etree_element_to_subscription(root)
Exemple #10
0
def _convert_response_to_topic(response):
    root = ETree.fromstring(response.body)
    return _convert_etree_element_to_topic(root)
Exemple #11
0
def _convert_response_to_subscription(response):
    root = ETree.fromstring(response.body)
    return _convert_etree_element_to_subscription(root)
Exemple #12
0
def _convert_response_to_topic(response):
    root = ETree.fromstring(response.body)
    return _convert_etree_element_to_topic(root)