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
Fixed #28184 -- Allowed passing a callable storage to FileField. #8477
Fixed #28184 -- Allowed passing a callable storage to FileField. #8477
Conversation
40ac0e4
to
8350a16
Compare
8350a16
to
b0a33ed
Compare
4a1f1e3
to
489d963
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @miigotu
Thanks for the effort here. Are you still up for finishing this PR?
Some comments to be addressed:
- The CI build still has failures, specifically
isort
andflake8
. Can you rebase and address those please? - "What happens if you don't return a valid storage type?" — It's worth adding a test here. Since we can check at import time it's worth checking we get a valid return type, and probably raising
ImproperlyConfigured
with a helpful message if not. (Does it actually blow up immediately, or do you get a runtime error later? Is that error clear — i.e. does it instantly show what the problem is? — Etc. Better to head these off at the pass.) - Docs.
Let me know if you need any input.
Yes, I'll fix the build first and then see about the other checks. About the type checking though, there is also no type checking in other places callables are allowed so I just did it the same way. I'll test what exactly DOES happen and see for sure. |
692763c
to
518e6aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @miigotu.
Thanks for the updates. A couple of quick points...
ccaa51a
to
446e6db
Compare
This is going to take me a bit more work/thought. These tests fail on master for me also. |
Hi @miigotu — GH's review panel seems to be failing me this morning... I'll try a comment 😄 Sorry if this ends up appearing several times. Hi @miigotu Thanks for updating here. It's looking good. 👍
It's a new feature so, it'll have to go in 2.2. Can you update accordingly?
|
535ca97
to
3b88530
Compare
@carltongibson I've addressed the changes from your last comments, and added an unforeseen way to use this in the example (mostly to make sure someone doesn't add a call method to their storage class and something unexpected happen) This build should pass, let me know if there are any other changes that need to be made, or if my added example is too much. |
3b88530
to
ed020dc
Compare
ed020dc
to
b5f7cd0
Compare
@miigotu Need help with this PR? |
Would have used this feature today if merged. Any help wanted? |
Yes. If you can get it ready I will accept PR to my repo. It will need rebased and updated. |
cfec459
to
f795976
Compare
f795976
to
e74c9d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carltongibson I'm not sure exactly what you mean? A failure case or a success case? Is it more to exemplify how someone could have a subclass of Storage that also has a I guess I just don't understand the goal of that one, we currently handle it the same way any other place a callable is allowed to be passed into the model manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miigotu Thanks 👍 I left few suggestions.
@carltongibson Ahh, the callable storage example I forgot about that. So that is what you wanted a test case around, lol. I think it's probably clearer without it also, but it is one of the primary use cases where storage would adapt automagically ;) I'll try and get some of these documentation changes in over the next few days f nobody else gets to it. I am shooting in the dark when doing this style of documentation since it's my first time. |
5fdc997
to
c5587e3
Compare
Co-authored-by: miigotu <miigotu@gmail.com>
c5587e3
to
77632fa
Compare
Adds the ability to pass a callable as the storage param of FileField, and testing for this new ability
See ticket 28184 for details.
Signed-off-by: miigotu miigotu@gmail.com