ipython/ipython — pull request #6892 by ssanderson (2014-11-10 06:28:43+00:00)
Title: Better support for recursive/parameterized Traits.

Makes subclasses of Container forward their `this_class` attribute to parameterized traits. This makes it possible to express patterns like:
```
class Tree(HasTraits):

value = Unicode()
leaves = List(This())
```
Prior to this change, the above pattern would barf on instantiation with an AttributeError because the `This` inside the list wouldn't have a `this_class` attribute.

Also adds two new traits, `ForwardDeclaredType` and `ForwardDeclaredInstance`. These use the existing runtime import machinery of `Type` and `Instance`, but automatically resolve relative to the module in which their containing class was defined. For example, it's now possible to do something like:
```
class Foo(HasTraits):
bar = ForwardDeclaredInstance('Bar')
bartype = ForwardDeclaredType(klass='Bar')

class Bar(object):
pass
```
You could hack this previously by doing
```
bar = Instance(__name__ + '.Bar')
```
but I think the explicit forward-declaration syntax is a bit cleaner/clearer.