class StaticJavascripts(object): """Middleware for intercepting requests for WebHelpers' included javascript files. Triggered when PATH_INFO begins with '/javascripts/'. """ def __init__(self): self.javascripts_app = \ StaticURLParser(os.path.dirname(javascript_path)) def __call__(self, environ, start_response): if environ.get('PATH_INFO', '').startswith('/javascripts/'): log.debug("Handling Javascript URL (Starts with /javascripts/)") return self.javascripts_app(environ, start_response) else: return self.javascripts_app.not_found(environ, start_response)