##// END OF EJS Templates
Make session subheader default configurable
Jason Grout -
Show More
@@ -49,7 +49,7 b' from IPython.utils.importstring import import_item'
49 from IPython.utils.jsonutil import extract_dates, squash_dates, date_default
49 from IPython.utils.jsonutil import extract_dates, squash_dates, date_default
50 from IPython.utils.py3compat import str_to_bytes
50 from IPython.utils.py3compat import str_to_bytes
51 from IPython.utils.traitlets import (CBytes, Unicode, Bool, Any, Instance, Set,
51 from IPython.utils.traitlets import (CBytes, Unicode, Bool, Any, Instance, Set,
52 DottedObjectName, CUnicode)
52 DottedObjectName, CUnicode, Dict)
53
53
54 #-----------------------------------------------------------------------------
54 #-----------------------------------------------------------------------------
55 # utility functions
55 # utility functions
@@ -292,6 +292,9 b' class Session(Configurable):'
292 username = Unicode(os.environ.get('USER',u'username'), config=True,
292 username = Unicode(os.environ.get('USER',u'username'), config=True,
293 help="""Username for the Session. Default is your system username.""")
293 help="""Username for the Session. Default is your system username.""")
294
294
295 subheader = Dict({}, config=True,
296 help="""Subheader dictionary, which serves as the default subheader fields for each message.""")
297
295 # message signature related traits:
298 # message signature related traits:
296
299
297 key = CBytes(b'', config=True,
300 key = CBytes(b'', config=True,
@@ -416,8 +419,9 b' class Session(Configurable):'
416 msg['msg_type'] = header['msg_type']
419 msg['msg_type'] = header['msg_type']
417 msg['parent_header'] = {} if parent is None else extract_header(parent)
420 msg['parent_header'] = {} if parent is None else extract_header(parent)
418 msg['content'] = {} if content is None else content
421 msg['content'] = {} if content is None else content
419 sub = {} if subheader is None else subheader
422 msg['header'].update(self.subheader)
420 msg['header'].update(sub)
423 if subheader is not None:
424 msg['header'].update(subheader)
421 return msg
425 return msg
422
426
423 def sign(self, msg_list):
427 def sign(self, msg_list):
General Comments 0
You need to be logged in to leave comments. Login now