Michael Shepanski avatar Michael Shepanski committed 76dae73

Dont require access_type to be defined; Default this to 'dropbox' or full access.

Comments (0)

Files changed (2)

 =======================
- Django Dropbox Backup
+ Django Database Backup
 =======================
 
 This Django application provides management commands to help backup and
 3. Include the required settings below.
    DBBACKUP_STORAGE = 'dbbackup.storage.dropbox_storage'
    DBBACKUP_TOKENS_FILEPATH = '<local_tokens_filepath>'
-   DBBACKUP_DROPBOX_CONFIG = {  # Dropbox API Configuration
-       'consumer_key': '<dropbox_app_key>',
-       'consumer_secret': '<dropbox_app_secret>',
-   }
+   DBBACKUP_DROPBOX_APP_KEY = '<dropbox_app_key>'
+   DBBACKUP_DROPBOX_APP_SECRET = '<dropbox_app_secret>'
 
 4. Now you're ready to use the backup management commands. The first time you
    run a command you'll be prompted to visit a Dropbox URL to allow DBBackup
     access your website. NOTE: Do not share these keys with anyone you do not
     trust with access to your Dropbox files.
 
-DBBACKUP_DROPBOX_CONFIG (required)
-    Dictionary containing Dropbox API configuration settings. Most of the
-    settings contain defaults that you do not need to worry about. However, the
-    two settings 'consumer_key' & 'consumer_secret' are required. You should
-    refer to the Dropbox API documention to see a list of other settings
-    available.
+DBBACKUP_DROPBOX_APP_KEY
+    Required string containing your Dropbox App Key.
+
+DBBACKUP_DROPBOX_APP_SECRET
+    Required string containing your Dropbox App Secret.
+
+DBBACKUP_DROPBOX_ACCESS_TYPE
+    String containing your Dropbox Access Type. This is either 'dropbox' or
+    'app_folder' depending on the access type specified when creating your
+    application on the Dropbox website. This defaults to 'dropbox', assuming
+    your application has full access to your Dropbox folder.
 
 DBBACKUP_DROPBOX_DIRECTORY (optional)
     The directory in Dropbox you wish to save your backups. By default this is

dbbackup/storage/dropbox_storage.py

 import os
 import tempfile
 from .base import BaseStorage, StorageError
-from ConfigParser import ConfigParser
 from dropbox.rest import ErrorResponse
 from django.conf import settings
 from dropbox.client import DropboxClient
 from dropbox import session
 
-DEFAULT_CONFIG = {
-    'consumer_key': None,
-    'consumer_secret': None,
-    'verifier': '',
-    'server': 'api.dropbox.com',
-    'content_server': 'api-content.dropbox.com',
-    'port': 80,
-    'request_token_url': 'https://api.dropbox.com/0/oauth/request_token',
-    'access_token_url': 'https://api.dropbox.com/0/oauth/access_token',
-    'authorization_url': 'https://www.dropbox.com/0/oauth/authorize',
-    'root': 'dropbox',
-}
+DEFAULT_ACCESS_TYPE = 'dropbox'
 
 
 ################################
     DROPBOX_DIRECTORY = '/%s/' % DROPBOX_DIRECTORY.strip('/')
     DBBACKUP_DROPBOX_APP_KEY = getattr(settings, 'DBBACKUP_DROPBOX_APP_KEY', None)
     DBBACKUP_DROPBOX_APP_SECRET = getattr(settings, 'DBBACKUP_DROPBOX_APP_SECRET', None)
-    DBBACKUP_DROPBOX_ACCESS_TYPE = getattr(settings, 'DBBACKUP_DROPBOX_ACCESS_TYPE', None)
+    DBBACKUP_DROPBOX_ACCESS_TYPE = getattr(settings, 'DBBACKUP_DROPBOX_ACCESS_TYPE', DEFAULT_ACCESS_TYPE)
     _request_token = None
     _access_token = None
 
             raise StorageError('%s storage requires DBBACKUP_DROPBOX_APP_KEY to be defined in settings.' % self.name)
         if not self.DBBACKUP_DROPBOX_APP_SECRET:
             raise StorageError('%s storage requires DBBACKUP_DROPBOX_APP_SECRET to be specified.' % self.name)
-        if not self.DBBACKUP_DROPBOX_ACCESS_TYPE:
-            raise StorageError('%s storage requires DBBACKUP_DROPBOX_ACCESS_TYPE to be specified.' % self.name)
 
     ###################################
     #  DBBackup Storage Methods
 
     def delete_file(self, filepath):
         """ Delete the specified filepath. """
-        response = self.run_dropbox_action(self.dropbox.file_delete, filepath)
+        self.run_dropbox_action(self.dropbox.file_delete, filepath)
 
     def list_directory(self):
         """ List all stored backups for the specified. """
         """ Connect and return a Dropbox client object. """
         self.read_token_file()
         sess = session.DropboxSession(self.DBBACKUP_DROPBOX_APP_KEY,
-                                      self.DBBACKUP_DROPBOX_APP_SECRET,
-                                      self.DBBACKUP_DROPBOX_ACCESS_TYPE)
+            self.DBBACKUP_DROPBOX_APP_SECRET, self.DBBACKUP_DROPBOX_ACCESS_TYPE)
         # Get existing or new access token and use it for this session
         access_token = self.get_access_token(sess)
         sess.set_token(access_token.key, access_token.secret)
         dropbox = DropboxClient(sess)
         # Test the connection by making call to get account_info
-        acct_info = dropbox.account_info()
+        dropbox.account_info()
         return dropbox
 
     def get_request_token(self, sess):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.