Skip to content

Commit

Permalink
[dropbox] Move settings to the class level to ease subclassing (#745)
Browse files Browse the repository at this point in the history
* Update dropbox.py

Added settings parameters as in s3boto3.py that way its easier to modify them when creating a  subclass

* Update dropbox.py

Co-authored-by: Josh Schneier <[email protected]>
  • Loading branch information
btywoniuk and jschneier authored Feb 2, 2020
1 parent 48bbad4 commit dfd3cac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions storages/backends/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ def _set_file(self, value):
@deconstructible
class DropBoxStorage(Storage):
"""DropBox Storage class for Django pluggable storage system."""
location = setting('DROPBOX_ROOT_PATH', '/')
oauth2_access_token = setting('DROPBOX_OAUTH2_TOKEN')
timeout = setting('DROPBOX_TIMEOUT', _DEFAULT_TIMEOUT)

CHUNK_SIZE = 4 * 1024 * 1024

def __init__(self, oauth2_access_token=None, root_path=None, timeout=None):
oauth2_access_token = oauth2_access_token or setting('DROPBOX_OAUTH2_TOKEN')
def __init__(self, oauth2_access_token=oauth2_access_token, root_path=location, timeout=timeout):
if oauth2_access_token is None:
raise ImproperlyConfigured("You must configure an auth token at"
"'settings.DROPBOX_OAUTH2_TOKEN'.")

self.root_path = root_path or setting('DROPBOX_ROOT_PATH', '/')
timeout = timeout or setting('DROPBOX_TIMEOUT', _DEFAULT_TIMEOUT)
self.root_path = root_path
self.client = Dropbox(oauth2_access_token, timeout=timeout)

def _full_path(self, name):
Expand Down

0 comments on commit dfd3cac

Please sign in to comment.