Show More
@@ -125,10 +125,10 b' from IPython.external import simplegeneric' | |||||
125 |
|
125 | |||
126 | import path |
|
126 | import path | |
127 | try: |
|
127 | try: | |
128 |
from IPython import genutils, |
|
128 | from IPython import genutils, generics | |
129 | except ImportError: |
|
129 | except ImportError: | |
130 | genutils = None |
|
130 | genutils = None | |
131 |
|
|
131 | generics = None | |
132 |
|
132 | |||
133 |
|
133 | |||
134 | __all__ = [ |
|
134 | __all__ = [ | |
@@ -2204,7 +2204,7 b' class AttributeDetail(Table):' | |||||
2204 | try: |
|
2204 | try: | |
2205 | from ibrowse import ibrowse |
|
2205 | from ibrowse import ibrowse | |
2206 | except ImportError: |
|
2206 | except ImportError: | |
2207 | # No curses (probably Windows) |
|
2207 | # No curses (probably Windows) => try igrid | |
2208 | try: |
|
2208 | try: | |
2209 | from igrid import igrid |
|
2209 | from igrid import igrid | |
2210 | except ImportError: |
|
2210 | except ImportError: | |
@@ -2218,27 +2218,21 b' else:' | |||||
2218 | __all__.append("ibrowse") |
|
2218 | __all__.append("ibrowse") | |
2219 |
|
2219 | |||
2220 |
|
2220 | |||
2221 |
# If we're running under IPython, |
|
2221 | # If we're running under IPython, register our objects with IPython's | |
2222 | # returns the object from Display.display(), else install a displayhook |
|
2222 | # generic function ``result_display``, else install a displayhook | |
2223 | # directly as sys.displayhook |
|
2223 | # directly as sys.displayhook | |
2224 | api = None |
|
2224 | if generics is not None: | |
2225 | if ipapi is not None: |
|
2225 | def display_display(obj): | |
2226 | try: |
|
2226 | return obj.display() | |
2227 | api = ipapi.get() |
|
2227 | generics.result_display.when_type(Display)(display_display) | |
2228 | except AttributeError: |
|
2228 | ||
2229 | pass |
|
2229 | def display_tableobject(obj): | |
2230 |
|
2230 | return display_display(defaultdisplay(obj)) | ||
2231 | if api is not None: |
|
2231 | generics.result_display.when_type(Table)(display_tableobject) | |
2232 | def displayhook(self, obj): |
|
2232 | ||
2233 | if isinstance(obj, type) and issubclass(obj, Table): |
|
2233 | def display_tableclass(obj): | |
2234 | obj = obj() |
|
2234 | return display_tableobject(obj()) | |
2235 | if isinstance(obj, Table): |
|
2235 | generics.result_display.when_type(Table.__metaclass__)(display_tableclass) | |
2236 | obj = defaultdisplay(obj) |
|
|||
2237 | if isinstance(obj, Display): |
|
|||
2238 | return obj.display() |
|
|||
2239 | else: |
|
|||
2240 | raise ipapi.TryNext |
|
|||
2241 | api.set_hook("result_display", displayhook) |
|
|||
2242 | else: |
|
2236 | else: | |
2243 | def installdisplayhook(): |
|
2237 | def installdisplayhook(): | |
2244 | _originalhook = sys.displayhook |
|
2238 | _originalhook = sys.displayhook |
@@ -1,3 +1,8 b'' | |||||
|
1 | 2008-01-21 Walter Doerwald <walter@livinglogic.de> | |||
|
2 | ||||
|
3 | * ipipe.py: Register ipipe's displayhooks via the generic function | |||
|
4 | generics.result_display() instead of using ipapi.set_hook(). | |||
|
5 | ||||
1 | 2008-01-19 Walter Doerwald <walter@livinglogic.de> |
|
6 | 2008-01-19 Walter Doerwald <walter@livinglogic.de> | |
2 |
|
7 | |||
3 | * ibrowse.py, igrid.py, ipipe.py: |
|
8 | * ibrowse.py, igrid.py, ipipe.py: |
General Comments 0
You need to be logged in to leave comments.
Login now