From 7380583c9ce00192831969b2a71c550b647c7627 Mon Sep 17 00:00:00 2001 From: Patrick Craston Date: Tue, 14 Apr 2015 12:35:15 +0100 Subject: [PATCH 1/2] Deal with StreamingHttpResponse in disk renderer Iterate over streaming_content if response is StreamingHttpResponse, otherwise use content --- django_medusa/renderers/disk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_medusa/renderers/disk.py b/django_medusa/renderers/disk.py index 76821e5..7834b8d 100644 --- a/django_medusa/renderers/disk.py +++ b/django_medusa/renderers/disk.py @@ -53,7 +53,11 @@ def _disk_render_path(args): outpath += "index.html" print(outpath) with open(outpath, 'wb') as f: - f.write(resp.content) + if resp.streaming: + for chunk in resp.streaming_content: + f.write(chunk) + else: + f.write(resp.content) class DiskStaticSiteRenderer(BaseStaticSiteRenderer): From fb1099cfcc222deec99cb018117ee159a3da06e6 Mon Sep 17 00:00:00 2001 From: luca bocchi Date: Fri, 8 May 2015 14:36:49 +0100 Subject: [PATCH 2/2] renderers.disk._disk_render_path: fix for handling HTTP response's status codes 301 or 302 (redirect) --- django_medusa/renderers/disk.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django_medusa/renderers/disk.py b/django_medusa/renderers/disk.py index 7834b8d..7301384 100644 --- a/django_medusa/renderers/disk.py +++ b/django_medusa/renderers/disk.py @@ -35,6 +35,9 @@ def _disk_render_path(args): outpath = os.path.join(DEPLOY_DIR, realpath) resp = client.get(path) + if resp.status_code == 301 or resp.status_code == 302: + print('%s - redirect - skipping...' % path) + return None if resp.status_code != 200: raise Exception if needs_ext: