Skip to content

Commit

Permalink
set json repsonse headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Oct 2, 2015
1 parent 896837b commit f6c2577
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.1 (unreleased)
----------------

- Nothing changed yet.
- set json repsonse headers
[jensens]


1.0 (2015-05-16)
Expand Down
7 changes: 6 additions & 1 deletion collective/jsonify/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def get_item(self):
except Exception, e:
etype = sys.exc_info()[0]
tb = pprint.pformat(traceback.format_tb(sys.exc_info()[2]))
return 'ERROR: exception wrapping object: %s: %s\n%s' % (etype, str(e), tb)
return 'ERROR: exception wrapping object: %s: %s\n%s' % (
etype, str(e), tb
)

passed = False
while not passed:
Expand All @@ -49,6 +51,7 @@ def get_item(self):
passed = False
else:
return ('ERROR: Unknown error serializing object: %s' % error)
self.REQUEST.response.setHeader("Content-type", "application/json")
return JSON


Expand All @@ -65,6 +68,7 @@ def get_children(self):
# Thus we need to convert it to a list
if not isinstance(children, list):
children = [item for item in children]
self.REQUEST.response.setHeader("Content-type", "application/json")
return json.dumps(children)


Expand All @@ -80,4 +84,5 @@ def get_catalog_results(self):
{"__builtins__": None}, {})
item_paths = [item.getPath() for item
in self.unrestrictedSearchResults(**query)]
self.REQUEST.response.setHeader("Content-type", "application/json")
return json.dumps(item_paths)

0 comments on commit f6c2577

Please sign in to comment.