-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Refs #2068: Do not reinstantiate staticfiles storage classes #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@matthiask would it be possible to wrap the |
@tim-schilling Yes, I think we could directly monkey-patch the |
I think either case works well. I haven't manipulated |
I have done too many hacks with If we want a quick bugfix release for #2068 I can finish this, but maybe this would also be a good fit for our Djangonauts? Especially if we can wait a few days or weeks for a fix. |
I'm good with waiting. |
I assigned #2068 to myself, thinking all this PR needed was tests, but now I see you were considering a different approach (monkey patching). I'm trying to understand the proposal to see if I can help. |
So, monkeypatching would mean something like this: def patched_url(self, path):
url = orig_url(path)
... our own customizations
return url
orig_url = storage.staticfiles_storage.url
storage.staticfiles_storage.url = patched_url It's a less tricky way to achieve basically the same thing my MRO hack did. I'm not immediately aware of any downsides either way. Also, runtime patching is frowned upon, but we have to do something ugly to add our instrumentation. |
I suspect the MRO hack may be less intrusive to other devs. If we monkey patch things, we'd want to consider using |
Superseded by #2097 |
Description
This change might address an issue where reinstantiating the staticfiles class inside our staticfiles panel would lose some attributes of the storage instance.
Fixes #2068
Checklist:
docs/changes.rst
.