Created
January 22, 2016 19:38
-
-
Save twobraids/2b1b900e8e179f3cc849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#============================================================================== | |
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