Skip to content
Prev Previous commit
Next Next commit
Return ints instead of EntityProperties
fix a few doc strings
  • Loading branch information
Dino Viehland committed Jun 4, 2012
commit f5851bffd473aceb0aa84c915e8be1074b6c4803
4 changes: 2 additions & 2 deletions src/azure/http/batchclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def commit_batch(self):
''' Resets batch flag and commits the batch requests. '''
if self.is_batch:
self.is_batch = False
resp = self.commit_batch_requests()
return resp
self.commit_batch_requests()


def commit_batch_requests(self):
''' Commits the batch requests. '''
Expand Down
17 changes: 10 additions & 7 deletions src/azure/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ class EntityProperty(WindowsAzureData):
def __init__(self, type=None, value=None):
self.type = type
self.value = value
pass

class Table(WindowsAzureData):
''' Only for intellicens and telling user the return type. '''
Expand Down Expand Up @@ -600,17 +599,21 @@ def _convert_xml_to_entity(xmlstr):

isnull = xml_property.getAttributeNS(METADATA_NS, 'null')
mtype = xml_property.getAttributeNS(METADATA_NS, 'type')
property = EntityProperty()


#if not isnull and no type info, then it is a string and we just need the str type to hold the property.
if not isnull and not mtype:
setattr(entity, name, value)
else: #need an object to hold the property
setattr(property, 'value', value)
if isnull:
setattr(property, 'isnull', str(isnull))
if mtype:
setattr(property, 'type', str(mtype))
if mtype == 'Edm.Int32' or mtype=='Edm.Int64':
property = int(value)
else:
property = EntityProperty()
setattr(property, 'value', value)
if isnull:
property.isnull = str(isnull)
if mtype:
property.type = str(mtype)
setattr(entity, name, property)

return entity
Expand Down
5 changes: 4 additions & 1 deletion src/azure/storage/cloudstorageaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
from azure.storage.queueservice import QueueService

class CloudStorageAccount:

"""Provides a factory for creating the blob, queue, and table services
with a common account name and account key. Users can either use the
factory or can construct the appropriate service directly."""

def __init__(self, account_name=None, account_key=None):
self.account_name = account_name
self.account_key = account_key
Expand Down
2 changes: 1 addition & 1 deletion src/azure/storage/queueservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class QueueService(_StorageClient):
'''
This is the main class managing Blob resources.
This is the main class managing queue resources.
account_name: your storage account name, required for all operations.
account_key: your storage account key, required for all operations.
'''
Expand Down
4 changes: 2 additions & 2 deletions src/codegenerator/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def output_import(output_file, class_name):
output_str += 'from azure.storage import (_update_storage_table_header, \n'
output_str += indent*8 + 'convert_table_to_xml, _convert_xml_to_table,\n'
output_str += indent*8 + 'convert_entity_to_xml, _convert_response_to_entity, \n'
output_str += indent*8 + '_convert_xml_to_entity)\n'
output_str += indent*8 + '_convert_xml_to_entity, _sign_storage_table_request)\n'

if 'Table' in class_name:
output_str += 'from azure.http.batchclient import _BatchClient\n'
Expand Down Expand Up @@ -329,7 +329,7 @@ def output_method_body(return_type, method_params, uri_param, req_protocol, req_
if 'servicebus' in req_host:
output_body += indent*2 + 'request.headers = _update_service_bus_header(request, self.account_key, self.issuer)\n'
elif 'table.core.windows.net' in req_host:
output_body += indent*2 + 'request.headers = _update_storage_table_header(request, self.account_name, self.account_key)\n'
output_body += indent*2 + 'request.headers = _update_storage_table_header(request)\n'
elif 'blob.core.windows.net' in req_host:
output_body += indent*2 + 'request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)\n'
elif 'queue.core.windows.net' in req_host:
Expand Down
2 changes: 1 addition & 1 deletion src/codegenerator/queue_input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ QueueService
[x-ms-version]
2011-08-18
[class-comment]
This is the main class managing Blob resources.
This is the main class managing queue resources.
account_name: your storage account name, required for all operations.
account_key: your storage account key, required for all operations.
[init]
Expand Down
15 changes: 6 additions & 9 deletions test/azuretest/test_tableservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ def sanity_get_entity(self):
'')
self.assertEquals(resp.PartitionKey, ln)
self.assertEquals(resp.RowKey, fn1)
self.assertEquals(resp.age.value, u'39')
self.assertEquals(resp.age.type, u'Edm.Int32')
self.assertEquals(resp.Birthday.value, u'20')
self.assertEquals(resp.Birthday.type, 'Edm.Int64')
self.assertEquals(resp.age, 39)
self.assertEquals(resp.Birthday, 20)

def sanity_query_entities(self):
resp = self.tc.query_entities(TABLE_NO_DELETE, '', '')
self.assertEquals(len(resp), 2)
self.assertEquals(resp[0].birthday.value, u'1973-10-04T00:00:00Z')
self.assertEquals(resp[1].Birthday.value, u'20')
self.assertEquals(resp[1].Birthday, 20)

def sanity_update_entity(self):
ln = u'Lastname'
Expand All @@ -222,8 +220,7 @@ def sanity_update_entity(self):
'')
self.assertEquals(resp.PartitionKey, ln)
self.assertEquals(resp.RowKey, fn)
self.assertEquals(resp.age.value, u'21')
self.assertEquals(resp.age.type, u'Edm.Int32')
self.assertEquals(resp.age, 21)
self.assertEquals(resp.sex, u'female')
self.assertEquals(resp.birthday.value, u'1991-10-04T00:00:00Z')
self.assertEquals(resp.birthday.type, 'Edm.DateTime')
Expand Down Expand Up @@ -273,7 +270,7 @@ def sanity_insert_or_replace_entity(self):
'')
self.assertEquals(resp.PartitionKey, ln)
self.assertEquals(resp.RowKey, fn)
self.assertEquals(resp.age.value, u'1')
self.assertEquals(resp.age, 1)
self.assertEquals(resp.sex, u'male')
self.assertFalse(hasattr(resp, "birthday"))
self.assertFalse(hasattr(resp, "sign"))
Expand All @@ -296,7 +293,7 @@ def sanity_merge_entity(self):
'')
self.assertEquals(resp.PartitionKey, ln)
self.assertEquals(resp.RowKey, fn)
self.assertEquals(resp.age.value, u'1')
self.assertEquals(resp.age, 1)
self.assertEquals(resp.sex, u'female')
self.assertEquals(resp.fact, u'nice person')
self.assertFalse(hasattr(resp, "birthday"))
Expand Down