New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1142: address deprecation of werkzeug.urls.url_parse #1143
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The rest of the attributes of Url (e.g. host, path, anchor) all return the IRI (internationalized) version of their values. I'm not sure why query is different.
dairiki
force-pushed
the
fix.werkzeug.urls.deprecation
branch
from
May 3, 2023 03:23
d868a4d
to
6af2683
Compare
dairiki
force-pushed
the
fix.werkzeug.urls.deprecation
branch
2 times, most recently
from
May 4, 2023 19:04
508fe93
to
4da30af
Compare
dairiki
added a commit
to dairiki/lektor
that referenced
this pull request
May 4, 2023
Our Publisher API involves passing a `werkzeug.urls.URL` instance to `Publisher.publish`. As this is an API assumed by custom publishers implemented by Lektor plugins out in the wild, we can not simply change the API. PR lektor#1143 — in the master branch — implements one approach to updating the API in a backward-compatible manner, but it is rather involved. For the sake of the 3.3.x branch, for now we pin werkzeug<2.4 and leave the Publisher API as it is.
2 tasks
dairiki
added a commit
to dairiki/lektor-website
that referenced
this pull request
May 4, 2023
dairiki
force-pushed
the
fix.werkzeug.urls.deprecation
branch
from
May 4, 2023 22:42
4da30af
to
3133953
Compare
dairiki
added a commit
to dairiki/lektor
that referenced
this pull request
May 5, 2023
Our Publisher API involves passing a `werkzeug.urls.URL` instance to `Publisher.publish`. As this is an API assumed by custom publishers implemented by Lektor plugins out in the wild, we can not simply change the API. PR lektor#1143 — in the master branch — implements one approach to updating the API in a backward-compatible manner, but it is rather involved. For the sake of the 3.3.x branch, for now we pin werkzeug<2.4 and leave the Publisher API as it is.
dairiki
added a commit
to dairiki/lektor
that referenced
this pull request
Sep 11, 2023
* refactor: deprecate unused method Pad.make_absolute_url * refactor!: change Url.query from URI-encoded to IRI-decoded value * fix: disuse deprecated werkzeug.urls functions * refactor(publisher): pass URLs as str rather than SplitResult tuples * fix(publisher): restore compatibility with existing publisher plugins * fix: parse_qsl has no 'separator' parameter for python < 3.7.10
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue(s) Resolved
Fixes #1142
Related Issues / Links
Documentation updates for this PR are in lektor/lektor-website#371
Description of Changes
This PR disuses
werkzeug.urls.url_parse
in favor of the equivalents from stdlib'surllib.parse
, thus avoiding deprecation warnings from werkzeug>=2.3.0, and (hopefully) ensuring compatibility with werkzeug 2.4.Breaking Change of Publisher API
Currently, (before this PR) the
target_url
parameter of thePublisher.publish
method was expected to be awerkzeug.urls.URL
instance. Sincewerkzeug.urls.URL
is going away, that is obviously not sustainable. In this PR we change to passing astr
fortarget_url
.Doing this the simple way, however, would break existing external plugins (e.g. lektor-algolia, lektor-gae, lektor-s3, lektor-netlify, lektor-git-src-publisher, lektor-quiniu, lektor-surge) that implement custom publishers.
To prevent such breakage, in this PR we pass a custom subclass of
str
that implements (most of) the attributes and methods ofwerkzeug.urls.URL
(but issues a deprecation warning when they are accessed.)Breaking Changelet — Url.query
Instances of
lektor.utils.Url
are what is exposed to jinja templates for Lektor record fields of type"url"
.This PR changes the semantics of
lektor.utils.Url.query
from returning the URI-encoded (ASCII) query to returning the IRI-encoded (internationalize, unicode) version of the query. The other similar attributes ofUrl
(e.g.Url.host
,Url.path
,Url.anchor
) all already returned the IRI versions, so I'm not sure why.query
was being treated differently.Deprecation — Pad.make_absolute_url
This PR deprecates
lektor.db.Pad.make_absolute_url
. We have not used it since 93de7d9, and, anyway,lektor.db.Pad.make_url
provides equivalent functionality.