1+ import os
12import pkg_resources
23import ssl
34import sys
@@ -52,6 +53,24 @@ def pinned_session(pool_maxsize=8):
5253 url_path_quote = urllib .parse .quote
5354 url_encode = urllib .parse .urlencode
5455
56+ DOMAIN = os .environ .get ('DROPBOX_DOMAIN' , '.dropboxapi.com' )
57+
58+ # Default short hostname for RPC-style routes.
59+ HOST_API = 'api'
60+
61+ # Default short hostname for upload and download-style routes.
62+ HOST_CONTENT = 'content'
63+
64+ # Default short hostname for longpoll routes.
65+ HOST_NOTIFY = 'notify'
66+
67+ # Default short hostname for the Drobox website.
68+ HOST_WWW = 'www'
69+
70+ API_HOST = os .environ .get ('DROPBOX_API_HOST' , HOST_API + DOMAIN )
71+ API_CONTENT_HOST = os .environ .get ('DROPBOX_API_CONTENT_HOST' , HOST_CONTENT + DOMAIN )
72+ API_NOTIFICATION_HOST = os .environ .get ('DROPBOX_API_NOTIFY_HOST' , HOST_NOTIFY + DOMAIN )
73+ WEB_HOST = os .environ .get ('DROPBOX_WEB_HOST' , HOST_WWW + DOMAIN )
5574
5675class OAuthToken (object ):
5776 """
@@ -65,11 +84,6 @@ def __init__(self, key, secret):
6584class BaseSession (object ):
6685 API_VERSION = 1
6786
68- API_HOST = "api.dropbox.com"
69- WEB_HOST = "www.dropbox.com"
70- API_CONTENT_HOST = "api-content.dropbox.com"
71- API_NOTIFICATION_HOST = "api-notify.dropbox.com"
72-
7387 def __init__ (self , consumer_key , consumer_secret , access_type = "auto" , locale = None , rest_client = rest .RESTClient ):
7488 """Initialize a DropboxSession object.
7589
@@ -151,6 +165,11 @@ def build_url(self, host, target, params=None):
151165 """
152166 return "https://%s%s" % (host , self .build_path (target , params ))
153167
168+ BaseSession .API_HOST = API_HOST
169+ BaseSession .API_CONTENT_HOST = API_CONTENT_HOST
170+ BaseSession .API_NOTIFICATION_HOST = API_NOTIFICATION_HOST
171+ BaseSession .WEB_HOST = WEB_HOST
172+
154173class DropboxSession (BaseSession ):
155174
156175 def set_token (self , access_token , access_token_secret ):
@@ -251,8 +270,6 @@ def build_access_headers(self, method, resource_url, params=None, request_token=
251270 """Build OAuth access headers for a future request.
252271
253272 Args:
254- - ``method``: The HTTP method being used (e.g. 'GET' or 'POST').
255- - ``resource_url``: The full url the request will be made to.
256273 - ``params``: A dictionary of parameters to add to what's already on the url.
257274 Typically, this would consist of POST parameters.
258275
0 commit comments