From f76f66f1f6de8fb931c9803145b0fb85f63c3ceb 2013-04-24 04:47:50
From: MinRK <benjaminrk@gmail.com>
Date: 2013-04-24 04:47:50
Subject: [PATCH] add manager and client as trait lets of ZMQInteractiveShell

required adding **kwarg passthrough in InteractiveShell parents

---

diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index 768b3e0..b7ceb98 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -421,11 +421,11 @@ class InteractiveShell(SingletonConfigurable):
 
     def __init__(self, config=None, ipython_dir=None, profile_dir=None,
                  user_module=None, user_ns=None,
-                 custom_exceptions=((), None)):
+                 custom_exceptions=((), None), **kwargs):
 
         # This is where traits with a config_key argument are updated
         # from the values on config.
-        super(InteractiveShell, self).__init__(config=config)
+        super(InteractiveShell, self).__init__(config=config, **kwargs)
         self.configurables = [self]
 
         # These are relatively independent and stateless
diff --git a/IPython/frontend/terminal/console/app.py b/IPython/frontend/terminal/console/app.py
index 3de14e7..bc60879 100644
--- a/IPython/frontend/terminal/console/app.py
+++ b/IPython/frontend/terminal/console/app.py
@@ -115,8 +115,8 @@ class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonConsoleApp):
         self.shell = ZMQTerminalInteractiveShell.instance(config=self.config,
                         display_banner=False, profile_dir=self.profile_dir,
                         ipython_dir=self.ipython_dir,
-                        kernel_manager=self.kernel_manager,
-                        kernel_client=self.kernel_client,
+                        manager=self.kernel_manager,
+                        client=self.kernel_client,
         )
 
     def init_gui_pylab(self):
@@ -125,7 +125,7 @@ class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonConsoleApp):
 
     def handle_sigint(self, *args):
         if self.shell._executing:
-            if self.kernel_manager.has_kernel:
+            if self.kernel_manager:
                 # interrupt already gets passed to subprocess by signal handler.
                 # Only if we prevent that should we need to explicitly call
                 # interrupt_kernel, until which time, this would result in a 
diff --git a/IPython/frontend/terminal/console/interactiveshell.py b/IPython/frontend/terminal/console/interactiveshell.py
index 2607157..c723fcb 100644
--- a/IPython/frontend/terminal/console/interactiveshell.py
+++ b/IPython/frontend/terminal/console/interactiveshell.py
@@ -1,12 +1,9 @@
 # -*- coding: utf-8 -*-
-"""Frontend of ipython working with python-zmq
+"""terminal client to the IPython kernel
 
-Ipython's frontend, is a ipython interface that send request to kernel and proccess the kernel's outputs.
-
-For more details, see the ipython-zmq design
 """
 #-----------------------------------------------------------------------------
-# Copyright (C) 2011 The IPython Development Team
+# Copyright (C) 2013 The IPython Development Team
 #
 # Distributed under the terms of the BSD License. The full license is in
 # the file COPYING, distributed as part of this software.
@@ -37,7 +34,7 @@ from IPython.core.alias import AliasManager, AliasError
 from IPython.core import page
 from IPython.utils.warn import warn, error, fatal
 from IPython.utils import io
-from IPython.utils.traitlets import List, Enum, Any
+from IPython.utils.traitlets import List, Enum, Any, Instance, Unicode
 from IPython.utils.tempdir import NamedFileInTemporaryDirectory
 
 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
@@ -105,12 +102,12 @@ class ZMQTerminalInteractiveShell(TerminalInteractiveShell):
         """
     )
 
-    def __init__(self, *args, **kwargs):
-        self.manager = kwargs.pop('kernel_manager', None)
-        self.client = kwargs.pop('kernel_client')
-        self.session_id = self.client.session.session
-        super(ZMQTerminalInteractiveShell, self).__init__(*args, **kwargs)
-        
+    manager = Instance('IPython.kernel.KernelManager')
+    client = Instance('IPython.kernel.KernelClient')
+    def _client_changed(self, name, old, new):
+        self.session_id = new.session.session
+    session_id = Unicode()
+
     def init_completer(self):
         """Initialize the completion machinery.
 
diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py
index 19ce96b..d6f40f4 100644
--- a/IPython/frontend/terminal/interactiveshell.py
+++ b/IPython/frontend/terminal/interactiveshell.py
@@ -368,11 +368,13 @@ class TerminalInteractiveShell(InteractiveShell):
     
     def __init__(self, config=None, ipython_dir=None, profile_dir=None,
                  user_ns=None, user_module=None, custom_exceptions=((),None),
-                 usage=None, banner1=None, banner2=None, display_banner=None):
+                 usage=None, banner1=None, banner2=None, display_banner=None,
+                 **kwargs):
 
         super(TerminalInteractiveShell, self).__init__(
             config=config, ipython_dir=ipython_dir, profile_dir=profile_dir, user_ns=user_ns,
-            user_module=user_module, custom_exceptions=custom_exceptions
+            user_module=user_module, custom_exceptions=custom_exceptions,
+            **kwargs
         )
         # use os.system instead of utils.process.system by default,
         # because piped system doesn't make sense in the Terminal: