From 5be0cc499c49f622148077a4fae87a491f5135e0 2011-05-03 22:01:20 From: Thomas Kluyver Date: 2011-05-03 22:01:20 Subject: [PATCH] Put the whole history interface into kernelmanager. --- diff --git a/IPython/frontend/qt/console/ipython_widget.py b/IPython/frontend/qt/console/ipython_widget.py index 291aaaf..6140776 100644 --- a/IPython/frontend/qt/console/ipython_widget.py +++ b/IPython/frontend/qt/console/ipython_widget.py @@ -212,7 +212,7 @@ class IPythonWidget(FrontendWidget): """ Reimplemented to make a history request. """ super(IPythonWidget, self)._started_channels() - self.kernel_manager.xreq_channel.history_tail(1000) + self.kernel_manager.xreq_channel.history(hist_access_type='tail', n=1000) #--------------------------------------------------------------------------- # 'ConsoleWidget' public interface diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 8955ca7..582a1c3 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -282,23 +282,40 @@ class XReqSocketChannel(ZmqSocketChannel): self._queue_request(msg) return msg['header']['msg_id'] - def history_tail(self, n=10, raw=True, output=False): - """Get the history list. + def history(self, raw=True, output=False, hist_access_type='range', **kwargs): + """Get entries from the history list. Parameters ---------- - n : int - The number of lines of history to get. raw : bool If True, return the raw input. output : bool If True, then return the output as well. + hist_access_type : str + 'range' (fill in session, start and stop params), 'tail' (fill in n) + or 'search' (fill in pattern param). + + session : int + For a range request, the session from which to get lines. Session + numbers are positive integers; negative ones count back from the + current session. + start : int + The first line number of a history range. + stop : int + The final (excluded) line number of a history range. + + n : int + The number of lines of history to get for a tail request. + + pattern : str + The glob-syntax pattern for a search request. Returns ------- The msg_id of the message sent. """ - content = dict(n=n, raw=raw, output=output, hist_access_type='tail') + content = dict(raw=raw, output=output, hist_access_type=hist_access_type, + **kwargs) msg = self.session.msg('history_request', content) self._queue_request(msg) return msg['header']['msg_id']