Custom filename extension handler in Twisted webserver for template rendering
I attempted to use a file processor, but in the end I ended up subclassing static.File and overriding the render() method. The only complication was that I didn't realize that my type (MakoFile) would be instantiated for each child - this was causing me to lose my local mako context at times. In the end I realize the each instance of the File class has a Registry() handed down.
So I subclassed Registry as MakoRegistry, stuck my template lookup and context in there and pushed it into the top level object. This is working so far.
I have a twisted web server with static files served in an htdocs/... hierarchy. I would like to pass all .template files to mako/jinja before returning them, but return non-templated static files directly. Does anyone have any insight on the best way to do this? I would like to avoid having to put them in a specific directory instead I would like to leave them in the natural file hierarchy.