Merge lp:~nicopace/charms/trusty/python-django/allowed_host_patch into lp:charms/python-django

Proposed by nicopace
Status: Merged
Merged at revision: 37
Proposed branch: lp:~nicopace/charms/trusty/python-django/allowed_host_patch
Merge into: lp:charms/python-django
Diff against target: 12 lines (+2/-1)
1 file modified
hooks/hooks.py (+2/-1)
To merge this branch: bzr merge lp:~nicopace/charms/trusty/python-django/allowed_host_patch
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Kevin W Monroe Approve
Review via email: mp+254958@code.launchpad.net

Description of the change

there is a bug that rised when implementing gunicorn tests, that showed a 400 error on every request to gunicorn published python-django charm.
While I was digging over that bug, i discovered that, despite the documentation stated that if you don't specify a django_allowed_hosts config value, the default would be the FQDN and IP Address of the host, but it wasn't working that way.
This patch solves that problem.

To post a comment you must log in.
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

I was able to verify the 400 errors without your changes, and I saw the default hostname/fqdn/ip were not being set in ./juju-settings/30-allowed.py.

I then applied your changes and verified successful page requests as well as correct defaults in 30-allowed.py when django_allowed_hosts is empty.

We'll get an official ~charmer ack soon, but until then, +1 LGTM. Thanks for the fix!

review: Approve
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2015-01-08 00:35:37 +0000
+++ hooks/hooks.py 2015-04-01 17:37:18 +0000
@@ -370,7 +370,8 @@
370 dst = os.path.join(settings_dir_path, '30-allowed.py')370 dst = os.path.join(settings_dir_path, '30-allowed.py')
371 ip = run('unit-get public-address').strip()371 ip = run('unit-get public-address').strip()
372 allowed = [socket.gethostname(), socket.getfqdn(), ip]372 allowed = [socket.gethostname(), socket.getfqdn(), ip]
373 if 'django_allowed_hosts' in config_data:373 if 'django_allowed_hosts' in config_data and \
374 config_data['django_allowed_hosts'].strip() != '':
374 allowed = config_data['django_allowed_hosts'].split(' ')375 allowed = config_data['django_allowed_hosts'].split(' ')
375 process_template('allowed_hosts.tmpl', {'allowed_hosts': allowed}, dst)376 process_template('allowed_hosts.tmpl', {'allowed_hosts': allowed}, dst)
376377

Subscribers

People subscribed via source and target branches

to all changes: