Subclassing static.File

Viewed 604

I'm new to Twisted and I'm having trouble with some necessary subclassing for the static.File in twisted. i'm trying to set request headers within the 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 subclass definition itself (pretty straightforward), while the second bit is the initialization portion from my code (this isn't all of my code). I've have also subclassed a resource.Resource object called TestHandler. WebFolder is another folder containing many static files.

However, I am getting most of these types of exception when making calls to the server.

Unhandled Error
Traceback (most recent call last):
Failure: exceptions.RuntimeError: Producer was not unregistered for /

With many different paths other than root.

1 Answers
Related