зеркало из
1
0
Форкнуть 0

Return ints instead of EntityProperties

fix a few doc strings
This commit is contained in:
Dino Viehland 2012-06-04 16:52:17 -07:00
Родитель 3394625186
Коммит f5851bffd4
7 изменённых файлов: 26 добавлений и 23 удалений

Просмотреть файл

@ -163,8 +163,8 @@ class _BatchClient(_HTTPClient):
''' 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. '''

Просмотреть файл

@ -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. '''
@ -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

Просмотреть файл

@ -17,7 +17,10 @@ from azure.storage.tableservice import TableService
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

Просмотреть файл

@ -33,7 +33,7 @@ from azure import (_validate_not_none, Feed,
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.
'''

Просмотреть файл

@ -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'
@ -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:

Просмотреть файл

@ -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]

Просмотреть файл

@ -192,16 +192,14 @@ class StorageTest(unittest.TestCase):
'')
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'
@ -222,8 +220,7 @@ class StorageTest(unittest.TestCase):
'')
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')
@ -273,7 +270,7 @@ class StorageTest(unittest.TestCase):
'')
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"))
@ -296,7 +293,7 @@ class StorageTest(unittest.TestCase):
'')
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"))