[IPython-dev] Displayhook configuration (Walter take heed!)

Ville Vainio vivainio at gmail.com
Fri Jan 13 14:36:53 EST 2006


I guess it's time to implement configurable display hooks.

I think the most lightweight chain-of-command implemention would be:

- Rewrite Prompts.py/CachedOutput._display() to do:

for displayer in ip_display_hooks():
  try:
    displayer.display(arg)
    break
  except TryNextHook:
    pass

- Move current CachedOutput._display to another class Default

ip_display_hooks() return the list with the current display hook as
the last item. It's also the "public api" for setting display hooks -
people just prepend their own display hooks by doing

ip_display_hooks().insert(0,PipePrinter())

(other places than 0 are legal too if the user thinks he knows what he's doing)

The fictional PipePrinter would check if it is of the wanted type, and
raise TryNextHook if not (or if the processing is only partial).

I could do this, but since Walter asked for this he might be the one
to give it a shot?

--
Ville Vainio    http://tinyurl.com/2prnb
  Can't you see the world is burning
  Can't you feel its Fire burning
  Don't you know we all are burning
  The Fire of Life       -- R.N.Taylor / Changes




More information about the IPython-dev mailing list