-
-
Notifications
You must be signed in to change notification settings - Fork 867
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
Make API consistent across backends #1460
Comments
The API is if the S3 implementation disagrees with the base class, that is a bug |
@dimbleby I do not agree. I think it's fair to say that all of the django-storages backends should present a consistent API, probably of Most likely the Django API should be similarly extended but I don't think it makes sense to restrict the functionality so harshly here. |
If classes inherit from I agree that this could be resolved either in the parent or the child (or both). Providing additional inheritance / mixin methods that do not contradict the base class is also fine. |
If we put aside typechecking then the Django-Storages classes do conform to the API. All additional args are kwargs with default values. |
Yeah but different backends taking different kwargs is pretty much exactly what OP is complaining about! |
Okay so it’s not a bug due to Django but within-library compat. Should just have the API extended to take kwargs and forget about this. Will open a feature request with Django and also can make this consistent here. |
The point of using a library like django-storages is to abstract away the difference between the cloud object storage solutions. The same code should execute the same tasks across the different backends without the developer having to worry about which backend is in use. django-storages does not hold up to this principle, because the API is not consistent across the different backends.
Here is a simple example:
This code doesn't work. Why? Because S3 supports passing the
expire
parameter to theurl
method, but Google does not.I'm just using the url function as an example. Ideally all the backends will have the same public methods with the same signatures. Then the same code can work regardless of which backend is being used. As the library is now, developers will have to write code such as
if azure:...
to account for these differences, and it somewhat defeats the purpose.The text was updated successfully, but these errors were encountered: