======================
Working with Deferreds
======================

$Id$

  >>> from cybertools.twisted.tests import tester

  >>> from cybertools.twisted.deferring import Deferring

  >>> class Demo(object):
  ...     color = 'green'

  >>> class Demo2(object):
  ...     color = 'red'
  ...     other = Demo()

  >>> demo = Demo()
  >>> demoDef = Deferring(demo)
  >>> col = demoDef.color
  >>> col
  <Deferring on ...>
  >>> print col
  <Deferring on ...>

  >>> def printIt(result):
  ...     print 'result:', str(result)

  >>> col.addCallback(printIt)
  <Deferring on ...>

  >>> tester.iterate()
  result: green
  >>> col
  <Deferring on 'green'>

  >>> demo2 = Demo2()
  >>> demo2Def = Deferring(demo2)
  >>> other = demo2Def.other
  >>> other
  <Deferring on <Deferring on ...>>

  >>> ocol = other.color

  >>> ocol.addCallback(printIt)
  <Deferring on ...>

  >>> tester.iterate()
  result: green

  >>> ocol
  <Deferring on 'green'>

  >>> other
  <Deferring on <Demo object ...>>
