-
Notifications
You must be signed in to change notification settings - Fork 48
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
Using "${navigation_root_url}" in Link edit on External lead to a wrong url #710
Comments
on localhost they return the same value ('/en' is a nav root): (Pdb) pp get_navigation_root(obj)
'/Plone/en'
(Pdb) pp "/".join(obj.getPhysicalPath())
'/Plone/en' but on a site with VHM still returns /Plone/en instead of /en :-/ |
This function is a no sense. It just return the Zope object path instead of the virtual path from the root of the site. People expect ${navigation_root_url} to be replaced with What is the use case here? |
BTW, we've the greatest Zope function to manipulate urls an paths. If we want to get the path relative to the portal or navigation root for an object we've the zope REQUEST
This works with every combination of VHM (including If you omit This should replace every
@petschki @1letter what do you think? I think this could be also a plone.api improvment, so people haven't to mess up with paths/relative urls. |
it should be enough to do For variable replacing I'd also assume to see the full url (because it says so) so we should consider renaming those util functions herer https://github.com/plone/plone.app.contenttypes/blob/master/plone/app/contenttypes/utils.py#L29-L52 to |
earlier in this year, i stumpled over url calculation and caching see: plone/plone.app.event#391 we should checked many use cases ;-) |
Oh ... thanks for the reminder 👍🏼 |
That is why I've asked what was the use case. The original (11 year ago circa) did this:
and did it the full url way. Than a refactoring changed it to use relative urls. I think it is safe to use absolute_url directly with no relative paths. But I would also fix:
with
@1letter Doing:
is maybe better and don't add the getRequest() stuff, less code too. But the original bug would be in RAMCache here. |
we've this clone too! used in the converter: but https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/serializer/dxfields.py uses:
|
This works with every combination of VHM (including _vh_, using mysite.com/Plone/ as public address) and with navigation root. This is a minimal change that fix the relative path. This function is used in https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/serializer/dxfields.py too For the discussion, see #710
#711 I've created a PR on it |
Should |
that should definitely be fixed! moving to |
it involves plone.app.contenttypes, plone.base, plone.app.z3cform and (optionally) plone.restapi. I've opened a specific issue: #712 |
Branch: refs/heads/master Date: 2024-11-14T13:15:48+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@151aac3 Update utils.py This works with every combination of VHM (including _vh_, using mysite.com/Plone/ as public address) and with navigation root. This is a minimal change that fix the relative path. This function is used in https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/serializer/dxfields.py too For the discussion, see plone/plone.app.contenttypes#710 Files changed: M plone/app/contenttypes/utils.py Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-14T13:20:41+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@64bc79f Update link_redirect_view.py Use absolute_url_path so it works well with VHM virtual paths and /PloneSiteID sites Files changed: M plone/app/contenttypes/browser/link_redirect_view.py Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-14T13:23:15+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@519fd2f Create 711.bugfix news Files changed: A news/711.bugfix Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-14T14:59:30+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@21ff30d Update link_redirect_view.py absolute_url_path() already return a leading '/' Files changed: M plone/app/contenttypes/browser/link_redirect_view.py Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-14T15:06:32+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@5fb4336 Update utils.py if path is '/' (didn't happen with getPhysicalPath), avoid that ${navigation_root_url}/sitemap is transformed to //sitemap Files changed: M plone/app/contenttypes/utils.py Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-14T14:08:49Z Author: pre-commit-ci[bot] (pre-commit-ci[bot]) <66853113+pre-commit-ci[bot]@users.noreply.github.com> Commit: plone/plone.app.contenttypes@0c6f362 [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Files changed: M plone/app/contenttypes/utils.py Repository: plone.app.contenttypes Branch: refs/heads/master Date: 2024-11-18T10:46:41+01:00 Author: Yuri (yurj) <[email protected]> Commit: plone/plone.app.contenttypes@db05318 Merge pull request #711 from plone/yurj-fix-relative-path fix use of relative urls in replace_link_variables_by_paths and in the Link view Files changed: A news/711.bugfix M plone/app/contenttypes/browser/link_redirect_view.py M plone/app/contenttypes/utils.py
plone.app.contenttypes/plone/app/contenttypes/utils.py
Lines 50 to 52 in 450888e
I think this should use:
from plone.base.navigationroot import get_navigation_root
get_navigation_root(obj)
because getPhysicalPath() contains '/Plone/' (or the path to Plone instance). On localhost:8080 this works ok. But with VHM and web site with a domain, a link using ${navigation_root_url} returns the navigation root + '/Plone' + path from the nav root instead of the navigation root + path from the nav root.
You can see easily on https://classic.demo.plone.org/en/demo/a-link:
you get this:
with the link pointing to:
https://classic.demo.plone.org/Plone/en/sitemap (note the
/Plone
part)The text was updated successfully, but these errors were encountered: