2
from zope.interface import implements
4
from twisted.internet import interfaces
7
"""A wrapper around a file-like object to make it behave as a Transport.
9
This doesn't actually stream the file to the attached protocol,
10
and is thus useful mainly as a utility for debugging protocols.
13
implements(interfaces.ITransport)
21
def __init__(self, file):
24
def write(self, data):
28
self.handleException()
29
# self._checkProducer()
31
def _checkProducer(self):
32
# Cheating; this is called at "idle" times to allow producers to be
33
# found and dealt with
35
self.producer.resumeProducing()
37
def registerProducer(self, producer, streaming):
38
"""From abstract.FileDescriptor
40
self.producer = producer
41
self.streamingProducer = streaming
43
producer.resumeProducing()
45
def unregisterProducer(self):
48
def stopConsuming(self):
49
self.unregisterProducer()
52
def writeSequence(self, iovec):
53
self.write("".join(iovec))
55
def loseConnection(self):
56
self.disconnecting = True
59
# XXX: According to ITransport, this should return an IAddress!
63
# XXX: According to ITransport, this should return an IAddress!
66
def handleException(self):
69
def resumeProducing(self):
70
# Never sends data anyways
73
def pauseProducing(self):
74
# Never sends data anyways
77
def stopProducing(self):
80
# Additional Q2Q Transport requirements
82
from vertex import q2q
83
return q2q.Q2QAddress('file.domain', 'peer.resource')