[ckan-changes] [ckan/ckan] c2aa9c: Call the i18n Middleware first before asking the a...

GitHub noreply at github.com
Tue Jun 7 15:33:29 UTC 2016


  Branch: refs/heads/poc-flask-views.common-url_for-take-2
  Home:   https://github.com/ckan/ckan
  Commit: c2aa9c0ac41d076802362a7fe13369cbd7b53f30
      https://github.com/ckan/ckan/commit/c2aa9c0ac41d076802362a7fe13369cbd7b53f30
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/config/middleware/__init__.py
    M ckan/config/middleware/common_middleware.py
    M ckan/config/middleware/flask_app.py
    M ckan/config/middleware/pylons_app.py

  Log Message:
  -----------
  Call the i18n Middleware first before asking the apps

The i18n will remove the locale part of the environ['PATH_INFO']
(eg `fr` in `/fr/dataset`) and set the necessary lang vars in the
environ. We need to remove that before asking the apps if they can
handle a request, otherwise localized URLs won't get recognized.


  Commit: 26c1bd3fb4b1bb6ad96c77a5f4b008dc0f390b78
      https://github.com/ckan/ckan/commit/26c1bd3fb4b1bb6ad96c77a5f4b008dc0f390b78
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/config/middleware/flask_app.py

  Log Message:
  -----------
  Add helper reference to the actual Flask stack


  Commit: 62f55d2c96f84983ce8efb8217e7286588cf23e0
      https://github.com/ckan/ckan/commit/62f55d2c96f84983ce8efb8217e7286588cf23e0
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/config/middleware/__init__.py

  Log Message:
  -----------
  Support for cross-app URL generation

In order for the URL generation to work in the context of both applications,
some changes are made at the top of the middleware stack just before
dispatching the request to the relevant app. Essentially, if Flask is serving
the request we create a Routes request_config object and attach the Routes
mapper to it, and if it is a Pylons request, we wrap it with
`flask_app.test_request_context(environ_overrides=environ)`


  Commit: bf51545dbeca029ccdf60737c3112f147594206f
      https://github.com/ckan/ckan/commit/bf51545dbeca029ccdf60737c3112f147594206f
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/lib/helpers.py

  Log Message:
  -----------
  New version of url_for that supports both Flask and Pylons

There's a lot of parameters handling to support both syntaxes:

Pylons
url = url_for(controller='api', action='action', ver=3,
       qualified=True)

Flask
url = url_for('api.action', ver=3, _external=True)

Essentially this calls the Flask url_for function and falls back to
Pylons if it wasn't found.


  Commit: 51805b2a94f7bd0139ea7d9fb5afe2936e8cd8b7
      https://github.com/ckan/ckan/commit/51805b2a94f7bd0139ea7d9fb5afe2936e8cd8b7
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

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

  Log Message:
  -----------
  Set SERVER_NAME on Flask config

Automatically set SERVER_NAME from the value of ckan.site_url. This is
needed so Flask is able to generate fully qualified URLs with
_external=True. One major thing to note is that when SERVER_NAME is set
up the incoming request `Host` header (`HTTP_HOST` in the WSGI environ)
must match its value, otherwise the Flask router will return a 404 even
if the route has been defined.

That's why we had to modify
1. The environ sent during the WSGI party invite requests
2. The environ sent with the test webtest app in tests


  Commit: 5d70f308fce34d53326b1bc2ca2aa618b2d72747
      https://github.com/ckan/ckan/commit/5d70f308fce34d53326b1bc2ca2aa618b2d72747
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/tests/helpers.py

  Log Message:
  -----------
  Allow to modify the configuration of the test app


  Commit: c9cef38ade36b369720d62fa5afe76b0e4a463eb
      https://github.com/ckan/ckan/commit/c9cef38ade36b369720d62fa5afe76b0e4a463eb
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M ckan/tests/lib/test_helpers.py

  Log Message:
  -----------
  New tests for Flask URL generation


Compare: https://github.com/ckan/ckan/compare/c2aa9c0ac41d^...c9cef38ade36


More information about the ckan-changes mailing list