Skip to content

Commit ac550d8

Browse files
Albo90phanak-sap
authored andcommitted
Added: prefix async getattr, atom response
1 parent 08a7a7f commit ac550d8

File tree

3 files changed

+11
-46
lines changed

3 files changed

+11
-46
lines changed

pyodata/client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
import pyodata.v2.model
77
import pyodata.v2.service
88
from pyodata.exceptions import PyODataException, HttpError
9-
from pyodata.v2.response import Response
109

1110

1211
async def _async_fetch_metadata(connection, url, logger):
1312
logger.info('Fetching metadata')
1413

1514
async with connection.get(url + '$metadata') as async_response:
16-
resp = Response()
17-
resp.url = async_response.url
18-
resp.headers = async_response.headers
19-
resp.status_code = async_response.status
20-
resp.content = await async_response.read()
15+
resp = pyodata.v2.service.ODataHttpResponse(url=async_response.url,
16+
headers=async_response.headers,
17+
status_code=async_response.status,
18+
content=await async_response.read())
2119

2220
return _common_fetch_metadata(resp, logger)
2321

pyodata/v2/response.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

pyodata/v2/service.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from pyodata.exceptions import HttpError, PyODataException, ExpressionError, ProgramError
2020
from . import model
21-
from .response import Response
2221

2322
LOGGER_NAME = 'pyodata.service'
2423

@@ -103,7 +102,8 @@ def decode(message):
103102
class ODataHttpResponse:
104103
"""Representation of http response"""
105104

106-
def __init__(self, headers, status_code, content=None):
105+
def __init__(self, headers, status_code, content=None, url=None):
106+
self.url = url
107107
self.headers = headers
108108
self.status_code = status_code
109109
self.content = content
@@ -327,11 +327,10 @@ async def async_execute(self):
327327
headers=headers,
328328
params=params,
329329
data=body) as async_response:
330-
response = Response()
331-
response.url = async_response.url
332-
response.headers = async_response.headers
333-
response.status_code = async_response.status
334-
response.content = await async_response.read()
330+
response = ODataHttpResponse(url=async_response.url,
331+
headers=async_response.headers,
332+
status_code=async_response.status,
333+
content=await async_response.read())
335334
return self._call_handler(response)
336335

337336
def execute(self):
@@ -889,7 +888,7 @@ def __getattr__(self, attr):
889888
raise AttributeError('EntityType {0} does not have Property {1}: {2}'
890889
.format(self._entity_type.name, attr, str(ex)))
891890

892-
async def getattr(self, attr):
891+
async def async_getattr(self, attr):
893892
"""Get cached value of attribute or do async call to service to recover attribute value"""
894893
try:
895894
return self._cache[attr]

0 commit comments

Comments
 (0)