Changeset 2965
- Timestamp:
- 01/21/08 12:05:57 (11 months ago)
- Files:
-
- ipython/trunk/IPython/Extensions/ipipe.py (modified) (3 diffs)
- ipython/trunk/doc/ChangeLog (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ipython/trunk/IPython/Extensions/ipipe.py
r2963 r2965 126 126 import path 127 127 try: 128 from IPython import genutils, ipapi128 from IPython import genutils, generics 129 129 except ImportError: 130 130 genutils = None 131 ipapi= None131 generics = None 132 132 133 133 … … 2205 2205 from ibrowse import ibrowse 2206 2206 except ImportError: 2207 # No curses (probably Windows) 2207 # No curses (probably Windows) => try igrid 2208 2208 try: 2209 2209 from igrid import igrid … … 2219 2219 2220 2220 2221 # If we're running under IPython, install an IPython displayhook that2222 # returns the object from Display.display(), else install a displayhook2221 # If we're running under IPython, register our objects with IPython's 2222 # generic function ``result_display``, else install a displayhook 2223 2223 # directly as sys.displayhook 2224 api = None 2225 if ipapi is not None: 2226 try: 2227 api = ipapi.get() 2228 except AttributeError: 2229 pass 2230 2231 if api is not None: 2232 def displayhook(self, obj): 2233 if isinstance(obj, type) and issubclass(obj, Table): 2234 obj = obj() 2235 if isinstance(obj, Table): 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) 2224 if generics is not None: 2225 def display_display(obj): 2226 return obj.display() 2227 generics.result_display.when_type(Display)(display_display) 2228 2229 def display_tableobject(obj): 2230 return display_display(defaultdisplay(obj)) 2231 generics.result_display.when_type(Table)(display_tableobject) 2232 2233 def display_tableclass(obj): 2234 return display_tableobject(obj()) 2235 generics.result_display.when_type(Table.__metaclass__)(display_tableclass) 2242 2236 else: 2243 2237 def installdisplayhook(): ipython/trunk/doc/ChangeLog
r2964 r2965 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 6 2008-01-19 Walter Doerwald <walter@livinglogic.de> 2 7
