'Called when data can be written.
@return: L{None} on success, an exception or a negative integer on
failure.
@see: L{twisted.internet.interfaces.IWriteDescriptor.doWrite}.'

def doWrite(self):

    if ((len(self.dataBuffer) - self.offset) < self.SEND_LIMIT):
        self.dataBuffer = _concatenate(self.dataBuffer, self.offset, self._tempDataBuffer)
        self.offset = 0
        self._tempDataBuffer = []
        self._tempDataLen = 0
    if self.offset:
        l = self.writeSomeData(lazyByteSlice(self.dataBuffer, self.offset))
    else:
        l = self.writeSomeData(self.dataBuffer)
    if (isinstance(l, Exception) or (l < 0)):
        return l
    self.offset += l
    if ((self.offset == len(self.dataBuffer)) and (not self._tempDataLen)):
        self.dataBuffer = ''
        self.offset = 0
        self.stopWriting()
        if ((self.producer is not None) and ((not self.streamingProducer) or self.producerPaused)):
            self.producerPaused = False
            self.producer.resumeProducing()
        elif self.disconnecting:
            return self._postLoseConnection()
        elif self._writeDisconnecting:
            self._writeDisconnected = True
            result = self._closeWriteConnection()
            return result
    return None
