-
-
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
Calculate settings when storage is instantiated; not imported #524
Conversation
Codecov Report
@@ Coverage Diff @@
## master #524 +/- ##
=========================================
Coverage ? 75.72%
=========================================
Files ? 12
Lines ? 1524
Branches ? 0
=========================================
Hits ? 1154
Misses ? 370
Partials ? 0
Continue to review full report at Codecov.
|
@jdufresne This looks good, but it will not merge cleanly after I merged on of your other changesets. Can you update? |
Thanks @sww314 I have rebased on to the latest master. |
Rebased to resolve merge conflicts. |
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.
These changes look good to me, but I would like another person to review as well.
@jschneier These changes look good to me. Can you review as well? |
Looking now. This will close what I consider by far the biggest issue in the original design of the library. |
I have rebased to resolve all merge conflicts. Ready for additional review. Thanks! |
@jschneier @jdufresne Now that 1.7 is out. Maybe we can get this merged for version 2? |
I've rebased this to the latest master. Feedback welcome. |
@jschneier Bumping this PR - it would be very useful for those of us having to initialise credentials from other sources (e.g. reading Google Cloud creds from an env var rather than a file). |
@jschneier, any indication as to when this might make it into an official release? Would be extremely useful as we often need to switch between multiple sets of storage settings on the fly. Thanks! |
Hi,
Thanks for the interest. I’ve been playing work catch up after coming back from vacation this week. I’m going to dedicate one day to django-storages this weekend and this is one of my top priorities.
… On Nov 15, 2018, at 12:50 PM, sushifan ***@***.***> wrote:
@jschneier <https://github.com/jschneier>, any indication as to when this might make it into an official release? Would be extremely useful as we often need to switch between multiple sets of storage settings on the fly. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#524 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACJB2IJJp4IdwaAVF1JjjAHO1mF6B79Pks5uvalwgaJpZM4VE4Sa>.
|
@sww314 Are you able to merge this? (Note that Travis last tested this PR several months ago, so it would be good to check they still pass.) |
Rebased. Travis is still green. |
Hi, is there still interest in this PR? I'll happily rebase if it will be reviewed for inclusion. Just let me know. |
I've been using the following workaround this entire time, but the original idea of this PR still seems like a great, essential feature... My workaround is defining multiple storage backends and using them as appropriate:
|
Yes, still interested. This greatly improves testability.
…On Thursday, March 5, 2020, sushifan ***@***.***> wrote:
Hi, is there still interest in this PR? I'll happily rebase if it will be
reviewed for inclusion. Just let me know.
I've been using the following workaround this entire time, but the
original idea of this PR still seems like a great, essential feature... My
workaround is defining multiple storage backends and using them as
appropriate:
from storages.backends.s3boto3 import S3Boto3Storage
class PrivateS3OverwriteStorage(S3Boto3Storage):
"""Only specify params that are different from those in Django settings."""
def __init__(self):
super().__init__(file_overwrite=True)
class PublicS3OverwriteStorage(S3Boto3Storage):
"""Only specify params that are different from those in Django settings."""
def __init__(self):
super().__init__(default_acl='public-read', file_overwrite=True, querystring_auth=False)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#524?email_source=notifications&email_token=AAREDWAG5MPOL7Q5WCQQQ4DRF7INTA5CNFSM4FITQSNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN57A6A#issuecomment-595325048>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAREDWHJ65SUS7GINAGIGN3RF7INTANCNFSM4FITQSNA>
.
|
Great! I have rebased. |
Can you please change the method name to |
Makes the storage classes usable with Django's override_settings. For example, projects can now change the S3 location & bucket when running their tests. Affects the following backends: - azure_storage - gcloud - s3boto3 The remaining storage backends do not need to be altered as they do no calculate settings at import time. The class BaseStorage was created to use a common pattern to initialize settings for various backends. Users of these backends can expect them to work consistently. This class is fully backwards compatible. Settings can now be set: - In settings.py - Using override_settings - As a class variable - As an argument to __init__ Closes #498 Completes all necessary backends and adds tests.
👍 done. |
@jdufresne @jschneier I was just updating an unrelated PR, but I was wondering should Since it will only take me a couple moments to write and I'm already updating an existing PR I'll just create a PR for this, and we can go from there. |
Custom storages aren't yet inheriting from But I'd also be fine with an implementation that return |
@jdufresne I was just going to update my comment with that, sorry, disregard my previous message. I'm not sure an empty |
Similar to jschneier/django-storages#524 - makes testing easier
…rted This allows the "storages.backends.s3boto3" module to be cleanly imported before Django settings are configured. This further supports the changes from jschneier#524. Removing "S3Boto3StorageFile.buffer_size" as a class variable does not affect the API surface of S3Boto3StorageFile, as "buffer_size" was always accessible as an instance variable.
…rted This allows the "storages.backends.s3boto3" module to be cleanly imported before Django settings are configured. This further supports the changes from jschneier#524. Removing "S3Boto3StorageFile.buffer_size" as a class variable does not affect the API surface of "S3Boto3StorageFile", as "buffer_size" was always accessible as an instance variable.
…rted (#930) This allows the "storages.backends.s3boto3" module to be cleanly imported before Django settings are configured. This further supports the changes from #524. Removing "S3Boto3StorageFile.buffer_size" as a class variable does not affect the API surface of "S3Boto3StorageFile", as "buffer_size" was always accessible as an instance variable.
…rted (jschneier#930) This allows the "storages.backends.s3boto3" module to be cleanly imported before Django settings are configured. This further supports the changes from jschneier#524. Removing "S3Boto3StorageFile.buffer_size" as a class variable does not affect the API surface of "S3Boto3StorageFile", as "buffer_size" was always accessible as an instance variable.
Makes the storage classes usable with Django's
override_settings
. For example, projects can now change the S3 location & bucket when running their tests. Affects the following backends:The remaining storage backends do not need to be altered as they do no calculate settings at import time.
The class
BaseStorage
was created to use a common pattern to initialize settings for various backends. Users of these backends can expect them to work consistently. This class is fully backwards compatible. Settings can now be set:Closes #498
Completes all necessary backends and adds tests.