diff options
author | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-09-07 10:14:27 +0100 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2012-09-07 13:42:08 +0100 |
commit | 9c3279221262057c7eb8ebdcb29f366dc4de66d5 (patch) | |
tree | f47e356a0c5a0d15f9a62cf08458d669dde358bb /morph-cache-server | |
parent | c2998750dbb3d79b7455a079aa3f3d243715a15f (diff) | |
download | morph-9c3279221262057c7eb8ebdcb29f366dc4de66d5.tar.gz |
Add ability to have 'writable' cache servers.
Since we need to be able to update the cache from builders, this patch
introduces a --enable-writes argument to morph-cache-server and also adds a
@writable decorator to the class ready for marking particular paths which are
only available when --enable-writes is set.
Diffstat (limited to 'morph-cache-server')
-rwxr-xr-x | morph-cache-server | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/morph-cache-server b/morph-cache-server index 827da10a..ba5f0b2a 100755 --- a/morph-cache-server +++ b/morph-cache-server @@ -55,6 +55,8 @@ class MorphCacheServer(cliapp.Application): default=defaults['artifact-dir']) self.settings.boolean(['direct-mode'], 'cache directories are directly managed') + self.settings.boolean(['enable-writes'], + 'enable the write methods (fetch and delete)') def process_args(self, args): app = Bottle() @@ -64,6 +66,23 @@ class MorphCacheServer(cliapp.Application): self.settings['bundle-dir'], self.settings['direct-mode']) + def writable(prefix): + """Selectively enable bottle prefixes. + + prefix -- The path prefix we are enabling + + If the runtime configuration setting --enable-writes is provided + then we return the app.get() decorator for the given path prefix + otherwise we return a lambda which passes the function through + undecorated. + + This has the effect of being a runtime-enablable @app.get(...) + + """ + if self.settings['enable-writes']: + return app.get(prefix) + return lambda fn: fn + @app.get('/sha1s') def sha1(): repo = self._unescape_parameter(request.query.repo) |