Configuration: server_url, server_path

This commit is contained in:
Jakub Warmuz
2015-05-01 10:08:33 +00:00
parent 54955009eb
commit 0cb012a9fd
2 changed files with 16 additions and 6 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ class Client(object):
# TODO: Allow for other alg types besides RS256
self.network = network2.Network(
"https://" + config.server, jwk.JWKRSA.load(self.account.key.pem))
config.server_url, jwk.JWKRSA.load(self.account.key.pem))
self.config = config
+15 -5
View File
@@ -28,6 +28,8 @@ class NamespaceConfig(object):
zope.interface.implements(interfaces.IConfig)
def __init__(self, namespace):
assert not namespace.server.startswith('https://')
assert not namespace.server.startswith('http://')
self.namespace = namespace
def __getattr__(self, name):
@@ -42,24 +44,32 @@ class NamespaceConfig(object):
def in_progress_dir(self): # pylint: disable=missing-docstring
return os.path.join(self.namespace.work_dir, constants.IN_PROGRESS_DIR)
@property
def server_path(self):
"""File path based on ``server``."""
return self.namespace.server.replace('/', os.path.sep)
@property
def server_url(self):
"""Full server URL (including HTTPS scheme)."""
return 'https://' + self.namespace.server
@property
def cert_key_backup(self): # pylint: disable=missing-docstring
return os.path.join(
self.namespace.work_dir, constants.CERT_KEY_BACKUP_DIR,
self.namespace.server.partition(":")[0])
self.server_path)
@property
def accounts_dir(self): #pylint: disable=missing-docstring
return os.path.join(
self.namespace.config_dir, constants.ACCOUNTS_DIR,
self.namespace.server.replace(':', '-').replace('/', '-'))
self.namespace.config_dir, constants.ACCOUNTS_DIR, self.server_path)
@property
def account_keys_dir(self): #pylint: disable=missing-docstring
return os.path.join(
self.namespace.config_dir, constants.ACCOUNTS_DIR,
self.namespace.server.replace(':', '-').replace('/', '-'),
constants.ACCOUNT_KEYS_DIR)
self.server_path, constants.ACCOUNT_KEYS_DIR)
# TODO: This should probably include the server name
@property