[ckan-changes] [ckan/ckan] cb761c: Replace shims in ckan.common with instances of wer...

GitHub noreply at github.com
Wed Jun 22 15:52:01 UTC 2016


  Branch: refs/heads/poc-flask-views.config
  Home:   https://github.com/ckan/ckan
  Commit: cb761c839bfeae2588e54e9b0c037ba85a692cd6
      https://github.com/ckan/ckan/commit/cb761c839bfeae2588e54e9b0c037ba85a692cd6
  Author: amercader <amercadero at gmail.com>
  Date:   2016-06-22 (Wed, 22 Jun 2016)

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

  Log Message:
  -----------
  Replace shims in ckan.common with instances of werkzeug's LocalProxy

The approach that we were following up until now meant that we needed to
override all relevant methods of the underlying objects. For objects
like request and session that meant __setattr__, __getattr__ and
__delattr__, but we were still missing things like __repr__, __dir__, etc

For dict-like objects like config this is even worse because you need to
consider many other ways of setting values (eg config[k] = v vs
config.update(), config[k] vs config.get(k), etc)

Werkzeug's LocalProxy does all that for us and moreover, and perhaps
more crucially allows us to treat them as thread-local safe, as both
Flask and Pylons do (with LocalProxy and StackedObjectProxy
respectively)




More information about the ckan-changes mailing list