def _request_deferred(request):
 request_callback = request.callback
 request_errback = request.errback
 def _restore_callbacks(result):
  request.callback = request_callback
  request.errback = request_errback
  return result
 d = defer.Deferred()
 d.addBoth(_restore_callbacks)
 if request.callback:
  d.addCallbacks(request.callback, request.errback)
 (request.callback, request.errback) = (d.callback, d.errback)
 return d

def _request_deferred ( request ) : request_callback = request . callback request_errback = request . errback def _restore_callbacks ( result ) : request . callback = request_callback request . errback = request_errback return result d = defer . Deferred ( ) d . addBoth ( _restore_callbacks ) if request . callback : d . addCallbacks ( request . callback , request . errback ) ( request . callback , request . errback ) = ( d . callback , d . errback ) return d
wrap a request inside a deferred .