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
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2015-01-08 00:35:37 +0000
3+++ hooks/hooks.py 2015-04-01 17:37:18 +0000
4@@ -370,7 +370,8 @@
5 dst = os.path.join(settings_dir_path, '30-allowed.py')
6 ip = run('unit-get public-address').strip()
7 allowed = [socket.gethostname(), socket.getfqdn(), ip]
8- if 'django_allowed_hosts' in config_data:
9+ if 'django_allowed_hosts' in config_data and \
10+ config_data['django_allowed_hosts'].strip() != '':
11 allowed = config_data['django_allowed_hosts'].split(' ')
12 process_template('allowed_hosts.tmpl', {'allowed_hosts': allowed}, dst)
13

Subscribers

People subscribed via source and target branches

to all changes: