Skip to content
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

Question about the plone_patterns_settings view #4064

Open
ale-rt opened this issue Nov 22, 2024 · 2 comments
Open

Question about the plone_patterns_settings view #4064

ale-rt opened this issue Nov 22, 2024 · 2 comments

Comments

@ale-rt
Copy link
Member

ale-rt commented Nov 22, 2024

Question

I have some doubts about the plone_patterns_settings view.

The data-base-url is defined as self.context.absolute_url(), see:

"data-base-url": self.context.absolute_url(),

This caused some javascript issues when using a view with a custom traverser (something like: @@custom-view/foo/bar).
What I experienced was that some JS ajax calls were done to my context url rather than my "traversed conxtet" URL:

I solved this issue by setting data-base-url to context_state.current_base_url().

Sample Code:

class CustomPatternsSettingsView(BasePatternsSettingsView):

    def __call__(self):
        context_state = getMultiAdapter(
            (self.context, self.request), name="plone_context_state"
        )
        result = super().__call__()
        if isinstance(self.request["PARENTS"][0], EditItemForm):
            result["data-base-url"] = context_state.current_base_url()
        return result

Should we rename the data-base-url to data-context-url?
Is it right that in the case of a view like @@custom-view/foo/bar the data-base-url should be the context URL?

What version of Plone/ Addons I am using:

Plone 6.0-latest, but this also happens on Plone 6.1.

@petschki
Copy link
Member

petschki commented Nov 22, 2024

I would assume, that the base-url (comming from the earlier used <base> tag) has the URL of the base content context.

Changeing its name will break some mockup implementations notably the registry view.

Maybe it would be better to use the @@plone_context_state/current_base_url as value instead (https://github.com/plone/plone.app.layout/blob/master/plone/app/layout/globals/context.py#L43)

@ale-rt
Copy link
Member Author

ale-rt commented Nov 22, 2024

Maybe it would be better to use the @@plone_context_state/current_base_url as value instead (https://github.com/plone/plone.app.layout/blob/master/plone/app/layout/globals/context.py#L43)

Yes, that's the one I am using (I updated my sample code that was badly anonymized by AI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants