I am new to Twisted and am having problems with some necessary subclass for static.File in twisted. I am trying to set request headers in a subclass.
class ResponseFile(static.File):
def render_GET(self, request):
request.setHeader('Content-Disposition', ['attachment ; filename="tick_db_export.csv"'])
static.File.render_GET(self, request)
if __name__ == "__main__":
from twisted.internet import reactor
root = ResponseFile('WebFolder')
testHandler = TestHandler()
root.putChild('main', testHandler)
reactor.listenTCP(3650, server.Site(root))
reactor.run()
The first bit of code is the definition of a subclass (quite simple), and the second bit is part of the initialization from my code (this is not all my code). I also subclassed the resource. Resource object called TestHandler. WebFolder is another folder containing many static files.
However, when making calls to the server, I get most of these types of exceptions.
Unhandled Error
Traceback (most recent call last):
Failure: exceptions.RuntimeError: Producer was not unregistered for /
With many different paths other than root.
source
share