Skip to content

Instantly share code, notes, and snippets.

@twobraids
Created January 22, 2016 19:38
Show Gist options
  • Save twobraids/2b1b900e8e179f3cc849 to your computer and use it in GitHub Desktop.
Save twobraids/2b1b900e8e179f3cc849 to your computer and use it in GitHub Desktop.
#==============================================================================
class ConnectionContextWithHost(S3ConnectionContext):
"""an alternative base class that specific implementations of Boto
connection can derive. It adds "host" to the configuration"""
required_config = Namespace()
required_config.add_option(
'host',
doc="The hostname",
default="",
reference_value_from='resource.boto',
)
required_config.calling_format = change_default(
S3ConnectionContext,
'calling_format',
'boto.s3.connection.OrdinaryCallingFormat'
)
#--------------------------------------------------------------------------
def _connect(self):
try:
return self.connection
except AttributeError:
self.connection = boto.s3.connect_to_region(
config.host,
**self._get_credentials
)
return self.connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment