Mercurial > p > roundup > code
comparison roundup/rest.py @ 5589:5a2de4c19109 REST-rebased
Fix an indentation bug
committer: Ralf Schlatterbeck <rsc@runtux.com>
| author | Chau Nguyen <dangchau1991@yahoo.com> |
|---|---|
| date | Wed, 30 Jan 2019 10:26:35 +0100 |
| parents | 6b3a9655a7d9 |
| children | 4d8746c73fdb |
comparison
equal
deleted
inserted
replaced
| 5588:6b3a9655a7d9 | 5589:5a2de4c19109 |
|---|---|
| 794 else: | 794 else: |
| 795 output = getattr( | 795 output = getattr( |
| 796 self, "%s_element" % method.lower() | 796 self, "%s_element" % method.lower() |
| 797 )(class_name, item_id, input) | 797 )(class_name, item_id, input) |
| 798 | 798 |
| 799 if format_output.lower() == "json": | 799 if format_output.lower() == "json": |
| 800 self.client.setHeader("Content-Type", "application/json") | 800 self.client.setHeader("Content-Type", "application/json") |
| 801 if pretty_output: | 801 if pretty_output: |
| 802 indent = 4 | 802 indent = 4 |
| 803 else: | |
| 804 indent = None | |
| 805 output = RoundupJSONEncoder(indent=indent).encode(output) | |
| 806 else: | 803 else: |
| 807 self.client.response_code = 406 | 804 indent = None |
| 808 output = "Content type is not accepted by client" | 805 output = RoundupJSONEncoder(indent=indent).encode(output) |
| 806 else: | |
| 807 self.client.response_code = 406 | |
| 808 output = "Content type is not accepted by client" | |
| 809 | 809 |
| 810 return output | 810 return output |
| 811 | 811 |
| 812 | 812 |
| 813 class RoundupJSONEncoder(json.JSONEncoder): | 813 class RoundupJSONEncoder(json.JSONEncoder): |
