Commit 255fd786 authored by Ivan Tyagov's avatar Ivan Tyagov

Merge branch 'jupyter_kernel_image_fix' into 'master'

Fix image display on jupyter

This fix is for bug 
https://nexedi.erp5.net/bug_module/20160212-76EAAC/view?ignore_layout:int=1
where the image base64 string was only showing. The error in this case was that the `mime_type` of content code_result was not being updated by the kernel before display.

Reported by : @Tyagov 
Please review: @Tyagov @kirr 

For testing, you can use this jupyter instance with updated kernel running : 
https://[2001:67c:1254:e:8b::335d]:8888/tree

There are also some example notebooks in the aforementioned jupyter.

See merge request !47
parents 5024cfdd 2dbcddd7
......@@ -43,7 +43,7 @@ md5sum = d7d4a7e19d55bf14007819258bf42100
[erp5-kernel]
<= download-file-base
filename = ERP5kernel.py.jinja
md5sum = 3dfc6a7c16828bff55dec4cf96b730d3
md5sum = eb07520fc189dcac2d3bd2db1368b1ba
[kernel-json]
<= download-file-base
......
......@@ -265,7 +265,25 @@ class ERP5Kernel(Kernel):
mime_type = 'text/plain'
try:
content = json.loads(self.response)
# Example format for the json result we are expecting is :
# content = {
# "status": "ok",
# "ename": null,
# "evalue": null,
# "traceback": null,
# "code_result": "",
# "mime_type": "text/plain"
# }
# So, we can easily use any of the key to update values as such.
# Getting code_result for succesfull execution of code
code_result = content['code_result']
# Update mime_type with the mime_type from the http response result
# Required in case the mime_type is anything other than 'text/plain'
mime_type = content['mime_type']
# Display to frontend the error message for content status as 'error'
if content['status']=='error':
reply_content = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment