diff --git a/CHANGELOG.md b/CHANGELOG.md index ead0287432a..0422e1143e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [2.0.7] - [Unreleased] +## [2.0.7] - 2017-04-07 ### Updated - Updated `plotly.min.js` to version 1.25.0 for `plotly.offline`. - See [the plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md) for additional information regarding the updates. +### Added +- Added check to verify the share key is enabled when secret charts are created. + ## [2.0.6] - 2017-03-20 ### Added - Added a new mimetype 'text/vnd.plotly.v1+html' for `iplot` outputs. @@ -37,8 +40,6 @@ Note: This release's installation was broken. It has been removed from PyPI See [https://github.com/nteract/nteract/pull/662](https://github.com/nteract/nteract/pull/662) for the associated PR in nteract. - As part of the above, plotly output now prints with a [custom mimetype](https://github.com/plotly/plotly.py/blob/f65724f06b894a5db94245ee4889c632b887d8ce/plotly/offline/offline.py#L348) - `application/vnd.plotly.v1+json` - -### Added - `memoize` decorator added to `plotly.utils` ### Changed diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index dd7067600b5..93597fb0870 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -1295,9 +1295,9 @@ def parse_grid_id_args(grid, grid_url): return grid.id -def add_share_key_to_url(plot_url): +def add_share_key_to_url(plot_url, attempt=0): """ - Update plot's url to include the secret key + Check that share key is enabled and update url to include the secret key """ urlsplit = six.moves.urllib.parse.urlparse(plot_url) @@ -1308,7 +1308,21 @@ def add_share_key_to_url(plot_url): body = {'share_key_enabled': True, 'world_readable': False} response = v2.files.update(fid, body) - return plot_url + '?share_key=' + response.json()['share_key'] + # Sometimes a share key is added, but access is still denied. + # Check that share_key_enabled is set to true and + # retry if this is not the case + # https://github.com/plotly/streambed/issues/4089 + if not v2.files.retrieve(fid).json()['share_key_enabled']: + attempt += 1 + if attempt == 50: + raise exceptions.PlotlyError( + "The sharekey could not be enabled at this time so the graph " + "is saved as private. Try again to save as 'secret' later." + ) + add_share_key_to_url(plot_url, attempt) + + url_share_key = plot_url + '?share_key=' + response.json()['share_key'] + return url_share_key def _send_to_plotly(figure, **plot_options):