From b87343be026cf1ceae5c9e04af5390d2630fd3bc Mon Sep 17 00:00:00 2001 From: amsb Date: Thu, 15 May 2014 13:20:29 -0400 Subject: [PATCH 1/2] Set template context debug=True in cactus serve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To facilitate easily disabling tracking code and the like, imitate Django DEBUG=True and django.core.context_processors.debug. Disable with cactus serve —no-debug. --- cactus/cli.py | 5 +++-- cactus/site.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cactus/cli.py b/cactus/cli.py index 932b924a..c04b8e97 100755 --- a/cactus/cli.py +++ b/cactus/cli.py @@ -48,9 +48,9 @@ def make_messages(path, config): site.make_messages() -def serve(path, config, port, browser): +def serve(path, config, port, browser, no_debug): """Serve the project and watch changes""" - site = cactus.Site(path, config) + site = cactus.Site(path, config, debug=not no_debug) site.serve(port=port, browser=browser) def domain_setup(path, config): @@ -85,6 +85,7 @@ def main(): parser_serve.add_argument('-p', '--port', default = 8000, type = int, help = 'The port on which to serve the site.') parser_serve.add_argument('-b', '--browser', action = 'store_true', help = 'Whether to open a browser for the site.') + parser_serve.add_argument('--no-debug', default = False, action = 'store_true', help = 'Disable debug mode.') parser_make_messages = subparsers.add_parser('messages:make', help='Create translation files for the current project') parser_make_messages.set_defaults(target=make_messages) diff --git a/cactus/site.py b/cactus/site.py index 052366a7..27e70264 100644 --- a/cactus/site.py +++ b/cactus/site.py @@ -46,7 +46,7 @@ class Site(SiteCompatibilityLayer): _parallel = PARALLEL_CONSERVATIVE #TODO: Test me _static = None - def __init__(self, path, config_paths=None, ui=None, + def __init__(self, path, config_paths=None, ui=None, debug=False, PluginManagerClass=None, ExternalManagerClass=None, DeploymentEngineClass=None): # Load the config engine @@ -59,6 +59,7 @@ def __init__(self, path, config_paths=None, ui=None, self.compress_extensions = self.config.get('compress', ['html', 'css', 'js', 'txt', 'xml']) self.fingerprint_extensions = self.config.get('fingerprint', []) self.locale = self.config.get("locale", None) + self.debug = debug # Verify our location looks correct self.path = path @@ -149,6 +150,7 @@ def setup(self): "USE_L10N": False, "LANGUAGE_CODE": self.locale, "LOCALE_PATHS": [self.locale_path], + "DEBUG": self.debug, }) django.conf.settings.configure(**settings) @@ -179,6 +181,7 @@ def context(self): 'static': [p for p in self.static()] }, '__CACTUS_SITE__': self, + 'debug': self.debug, # imitate django.core.context_processors.debug } # Also make lowercase work From 9b9db114de5aab64fdad17c797f02e9743750765 Mon Sep 17 00:00:00 2001 From: amsb Date: Tue, 20 May 2014 17:24:09 -0400 Subject: [PATCH 2/2] Remove explicit host in boto.connect_s3 call Explicitly setting host in s3_connect to s3.amazonaws.com interferes with boto using correct host for region, causing Broken Pipe failures when uploading larger files. --- cactus/deployment/s3/engine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cactus/deployment/s3/engine.py b/cactus/deployment/s3/engine.py index 0c2cd614..084704e9 100644 --- a/cactus/deployment/s3/engine.py +++ b/cactus/deployment/s3/engine.py @@ -23,7 +23,7 @@ class S3DeploymentEngine(BaseDeploymentEngine): config_bucket_name = "aws-bucket-name" config_bucket_website = "aws-bucket-website" - _s3_api_endpoint = 's3.amazonaws.com' + #_s3_api_endpoint = 's3.amazonaws.com' _s3_port = 443 _s3_is_secure = True _s3_https_connection_factory = None @@ -48,7 +48,7 @@ def _create_connection(self): aws_access_key, aws_secret_key = self.credentials_manager.get_credentials() return boto.connect_s3(aws_access_key.strip(), aws_secret_key.strip(), - host=self._s3_api_endpoint, is_secure=self._s3_is_secure, port=self._s3_port, + is_secure=self._s3_is_secure, port=self._s3_port, https_connection_factory=self._s3_https_connection_factory) def get_bucket(self):