[ckan-changes] [ckan/ckan] 626398: Do not automatically set SERVER_NAME

GitHub noreply at github.com
Fri Aug 5 14:08:20 UTC 2016


  Branch: refs/heads/poc-flask-views
  Home:   https://github.com/ckan/ckan
  Commit: 626398088a05ae11802bc3c1dd942073a616f760
      https://github.com/ckan/ckan/commit/626398088a05ae11802bc3c1dd942073a616f760
  Author: amercader <amercadero at gmail.com>
  Date:   2016-08-05 (Fri, 05 Aug 2016)

  Changed paths:
    M ckan/config/middleware/__init__.py
    M ckan/config/middleware/flask_app.py
    M ckan/tests/helpers.py

  Log Message:
  -----------
  Do not automatically set SERVER_NAME

Apart from being magic that we want to avoid, the main cause of concern
of doin gthis is that when SERVER_NAME is set, the Flask router requires
the incoming URL (HTTP_HOST on environ) to have the same host as the one
defined in SERVER_NAME, otherwise it won't match the URL and return a
404. For example if ckan.site_url is set to http://localhost:5000
(so SERVER_NAME is localhost:5000), calls to http://127.0.0.1:5000 or
http://0.0.0.0:5000 won't work.

This would cause massive confusion on users, specially during
development or early deployment stages, so it's best to avoid it.

For the Flask url_for to work on Pylons requests though, we need to wrap
the Pylons request in a test_request_context, rather than an app_context.




More information about the ckan-changes mailing list