##// END OF EJS Templates
BUG: Fix broken codemirror highlighting on file rename....
BUG: Fix broken codemirror highlighting on file rename. When a users uses the rename dialog in the text editor, we call _set_mode_for_model on the returned model. The expected model to be returned from rename has no value for mimetype, which causes us to pass `undefined` to `CodeMirror.findModeByMIME`, which returns `undefined` back. We then try access an attribute of the (undefined) return value, causing an error. This now properly checks whether the `mimetype` attribute is set on the input model.

File last commit:

r18606:776d1fa8
r19787:24e75c0b
Show More
notebooknode.py
21 lines | 535 B | text/x-python | PythonLexer
"""NotebookNode - adding attribute access to dicts"""
from IPython.utils.ipstruct import Struct
class NotebookNode(Struct):
"""A dict-like node with attribute-access"""
pass
def from_dict(d):
"""Convert dict to dict-like NotebookNode
Recursively converts any dict in the container to a NotebookNode
"""
if isinstance(d, dict):
return NotebookNode({k:from_dict(v) for k,v in d.items()})
elif isinstance(d, (tuple, list)):
return [from_dict(i) for i in d]
else:
return d