Skip to content

Commit

Permalink
changed logic to be safer
Browse files Browse the repository at this point in the history
  • Loading branch information
srri committed Dec 6, 2014
1 parent f43e255 commit f434adc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions boto/s3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def connect(self, **kw_params):
:rtype: Connection object
:return: The connection to this regions endpoint
"""

if self.connection_cls:
return self.connection_cls(host=self.endpoint, **kw_params)

Expand All @@ -62,8 +61,14 @@ def regions():
def connect_to_region(region_name, **kw_params):
for region in regions():
if 'host' in kw_params.keys():
region.endpoint = kw_params['host']
del kw_params['host']
# Make sure the host specified is not nothing
if kw_params['host'] not in ['', None]:
region.endpoint = kw_params['host']
del kw_params['host']
return region.connect(**kw_params)
# If it is nothing then remove it from kw_params and proceed with default
else:
del kw_params['host']
if region.name == region_name:
return region.connect(**kw_params)
return None

0 comments on commit f434adc

Please sign in to comment.