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

Fix adapter registration #368

Merged
merged 2 commits into from
Jun 16, 2024
Merged

Fix adapter registration #368

merged 2 commits into from
Jun 16, 2024

Conversation

gforcada
Copy link
Sponsor Member

I was trying to add some extra classes on the <body> and I expected to be an adapter to extend the functionality, and indeed, there it was: plone.app.layout.globals.interfaces.IBodyClassAdapter

Even better, there is already an example adapter on plone.app.layout.globals.layout.DefaultBodyClasses 🤩

There is one catch though, the adapter is not registered in ZCML (so that it gets a name) and is actually a multi adapter (context, request), but it was only registered as a single adapter.

Anyway, long story short: here is a fix for it 🎉

I'm wondering if it would make sense to already split the LayoutPolicy (also in p.a.l.g.layout) and create smaller adapters? 🤔

Anyway, meanwhile we can fix the actual code, so anyone else wanting to add some extra classes on the <body> class does not have to try to figure out how that works 😄

And it needs to be registered in ZCML to get a name.
@mister-roboto
Copy link

@gforcada thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@yurj
Copy link

yurj commented May 13, 2024

@gforcada
Copy link
Sponsor Member Author

Oh, nice, I thought there were no docs, I did not even do a search (my laziness, sorry 🤚🏾 ). But to me the docs look fine 🤔 but the ZCA is still a bit of a mystery for me 😓

Copy link
Sponsor Member

@jensens jensens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good catch. I only know one implementation which is the one in Mosaic somewhere which works fine.

Copy link
Sponsor Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially I think this default adapter is only meant as an example, it does not actually return any classes. But as example it indeed needs a fix, otherwise others copy it and it does not work.

@mauritsvanrees mauritsvanrees merged commit 52e228e into master Jun 16, 2024
9 of 13 checks passed
@mauritsvanrees mauritsvanrees deleted the fix-adapter-registration branch June 16, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants