Flask-gzip icon indicating copy to clipboard operation
Flask-gzip copied to clipboard

Allow the app initialization to be postponed

Open notpushkin opened this issue 5 years ago • 0 comments

This is a widely used pattern (even in the Flask Extension Development docs) and is useful for all kinds of tricks. My usecase is not a really good one but it would work OK:

app = Flask()
cache = Cache(app)
gzip = Gzip()
gzip.after_request = \
    cache.memoize(timeout=24 * 60 * 60, key_prefix="gzip")(gzip.after_request)
gzip.init_app(app)

Right now one would need to subclass Gzip in order to do that.

notpushkin avatar Feb 06 '20 10:02 notpushkin