docs: def defer(self, opres):
          """
          Converts a raw :class:`couchbase.results.AsyncResult` object
          into a :class:`Deferred`.
  
          This is shorthand for the following "non-idiom"::
  
            d = Deferred()
            opres = cb.upsert("foo", "bar")
            opres.callback = d.callback
  
            def d_err(res, ex_type, ex_val, ex_tb):
                d.errback(opres, ex_type, ex_val, ex_tb)
  
            opres.errback = d_err
            return d
  
          :param opres: The operation to wrap
          :type opres: :class:`couchbase.results.AsyncResult`
  
          :return: a :class:`Deferred` object.
  
          Example::
  
            opres = cb.upsert("foo", "bar")
            d = cb.defer(opres)
            def on_ok(res):
                print("Result OK. Cas: {0}".format(res.cas))
            d.addCallback(opres)
  
  
          """
          d = Deferred()
          opres.callback = d.callback
  
          def _on_err(mres, ex_type, ex_val, ex_tb):
              try:
                  raise ex_type(ex_val)
              except CouchbaseError:
                  d.errback()
          opres.errback = _on_err
          return d