Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Commit ce403e0

Browse files
committed
using->location
1 parent 89c6361 commit ce403e0

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

coreapi/codecs/corejson.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def _document_to_primative(node, base_url=None):
9090
ret = OrderedDict({'name': node.name})
9191
if node.required:
9292
ret['required'] = True
93-
if node.type:
94-
ret['type'] = node.type
93+
if node.location:
94+
ret['location'] = node.location
9595
return ret
9696

9797
elif isinstance(node, Object):
@@ -168,7 +168,7 @@ def _primative_to_document(data, base_url=None):
168168
# Transform the strings or dicts into strings or Field instances.
169169
fields = [
170170
item if isinstance(item, string_types) else
171-
Field(item['name'], required=bool(item.get('required', False)), type=str(item.get('type', '')))
171+
Field(item['name'], required=bool(item.get('required', False)), location=str(item.get('type', '')))
172172
for item in fields
173173
]
174174

coreapi/document.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def _key_sorting(item):
3636

3737
# The field class, as used by Link objects:
3838

39-
Field = namedtuple('Field', ['name', 'required', 'type'])
39+
Field = namedtuple('Field', ['name', 'required', 'location'])
4040
Field.__new__.__defaults__ = (False, '')
4141

4242

4343
def required(name):
44-
return Field(name, required=True, type='')
44+
return Field(name, required=True, location='')
4545

4646

4747
# The Core API primatives:
@@ -195,7 +195,7 @@ def __init__(self, url=None, action=None, inplace=None, fields=None):
195195
self._action = '' if (action is None) else action
196196
self._inplace = inplace
197197
self._fields = () if (fields is None) else tuple([
198-
item if isinstance(item, Field) else Field(item, required=False, type='')
198+
item if isinstance(item, Field) else Field(item, required=False, location='')
199199
for item in fields
200200
])
201201

coreapi/transport.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def get_params(self, method, link, params=None):
6161
query_params = {}
6262
form_params = {}
6363
for key, value in params.items():
64-
if key not in fields or not fields[key].type:
64+
if key not in fields or not fields[key].location:
6565
# Default is 'query' for 'GET'/'DELETE', and 'form' others.
66-
param_type = 'query' if method in ('GET', 'DELETE') else 'form'
66+
location = 'query' if method in ('GET', 'DELETE') else 'form'
6767
else:
68-
param_type = fields[key].type
68+
location = fields[key].location
6969

70-
if param_type == 'path':
70+
if location == 'path':
7171
path_params[key] = value
72-
elif param_type == 'query':
72+
elif location == 'query':
7373
query_params[key] = value
7474
else:
7575
form_params[key] = value

tests/test_codecs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_link_encodings(json_codec):
152152
'link': Link(
153153
action='post',
154154
inplace=True,
155-
fields=['optional', Field('required', required=True, type='path')]
155+
fields=['optional', Field('required', required=True, location='path')]
156156
)
157157
})
158158
bytes = json_codec.dump(doc, indent=True)
@@ -169,7 +169,7 @@ def test_link_encodings(json_codec):
169169
{
170170
"name": "required",
171171
"required": true,
172-
"type": "path"
172+
"location": "path"
173173
}
174174
]
175175
}

tests/test_transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def mockreturn(method, url, **opts):
7777
link = Link(
7878
url='http://example.org/{user_id}/',
7979
action='get',
80-
fields=[Field(name='user_id', type='path')]
80+
fields=[Field(name='user_id', location='path')]
8181
)
8282
doc = http.transition(link, params={'user_id': 123})
8383
assert doc == {'example': 'http://example.org/123/'}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy