Mercurial > p > roundup > code
changeset 5600:e2c74d8121f3 REST-rebased
Update resource links
.. to match the recently URI changes
committer: Ralf Schlatterbeck <rsc@runtux.com>
| author | Chau Nguyen <dangchau1991@yahoo.com> |
|---|---|
| date | Wed, 30 Jan 2019 10:26:35 +0100 |
| parents | a76d88673375 |
| children | fcbeff272828 |
| files | roundup/rest.py test/test_rest.py |
| diffstat | 2 files changed, 13 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/rest.py Wed Jan 30 10:26:35 2019 +0100 +++ b/roundup/rest.py Wed Jan 30 10:26:35 2019 +0100 @@ -238,7 +238,8 @@ protocol = 'http' host = self.client.env['HTTP_HOST'] tracker = self.client.env['TRACKER_NAME'] - self.base_path = '%s://%s/%s/rest/' % (protocol, host, tracker) + self.base_path = '%s://%s/%s/rest' % (protocol, host, tracker) + self.data_path = self.base_path + '/data' def props_from_args(self, cl, args, itemid=None): """Construct a list of properties from the given arguments, @@ -393,7 +394,7 @@ raise Unauthorised('Permission to view %s denied' % class_name) class_obj = self.db.getclass(class_name) - class_path = self.base_path + class_name + class_path = '%s/%s/' % (self.data_path, class_name) # Handle filtering and pagination filter_props = {} @@ -494,7 +495,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'attributes': dict(result) } @@ -537,8 +538,8 @@ result = { 'id': item_id, 'type': type(data), - 'link': "%s%s%s/%s" % - (self.base_path, class_name, item_id, attr_name), + 'link': "%s/%s/%s/%s" % + (self.data_path, class_name, item_id, attr_name), 'data': data } @@ -597,7 +598,7 @@ raise UsageError("Must provide the %s property." % msg) # set the header Location - link = self.base_path + class_name + item_id + link = '%s/%s/%s' % (self.data_path, class_name, item_id) self.client.setHeader("Location", link) # set the response body @@ -650,7 +651,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'attribute': result } return 200, result @@ -701,7 +702,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'attribute': result } @@ -885,7 +886,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'result': result } else: @@ -914,7 +915,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'attribute': result } return 200, result @@ -980,7 +981,7 @@ result = { 'id': item_id, 'type': class_name, - 'link': self.base_path + class_name + item_id, + 'link': '%s/%s/%s' % (self.data_path, class_name, item_id), 'attribute': result } return 200, result
--- a/test/test_rest.py Wed Jan 30 10:26:35 2019 +0100 +++ b/test/test_rest.py Wed Jan 30 10:26:35 2019 +0100 @@ -146,7 +146,7 @@ status=self.db.status.lookup('open'), priority=self.db.priority.lookup('critical') ) - base_path = self.dummy_client.env['PATH_INFO'] + 'issue' + base_path = self.dummy_client.env['PATH_INFO'] + 'data/issue/' # Retrieve all issue status=open form = cgi.FieldStorage()
