-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add numberOfFolderishDocuments to catalog metadata #118
base: main
Are you sure you want to change the base?
Conversation
…e in folder contents in Volto.
@jaroel thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
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! |
Querying the catalog inside an indexer will kill any chance on having a speedy catalog rebuild. Any old DX Container is indicative of obj being a branch node instead of a leaf. |
|
||
|
||
@indexer(IFolderishDocument) | ||
def numberOfFolderishDocuments(obj): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel I think this metadata will not be updated if we add a content in the container. Indexing would have to be called in the event of adding content. I saw a discussion about this at: https://community.plone.org/t/indexing-how-to-index-contained-items/17428
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding an indexer, not an event listener. This works just fine (tm).
Thanks for having a look though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaroel surprisingly for me it works! I saw that when we add content to a container, it is reindexed. Even its modification date is changed.
@mauritsvanrees @jensens @davisagli , was that thought or is it an "accident"? Indexing is one of the most expensive things in Plone. If this has not been thought of, it would be good to remove this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wesleybl I don't think that is intentional. Unfortunately changing it could be disruptive since existing implementations are probably relying on it happening. So I would say we can change it in Plone 7 (but maybe there is a way to make it available in an opt-in fashion in Plone 6)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be intentional. Think only of caching: if content is added to a container, but this does not mark the container as changed, then you will keep getting the previous version, and not see the new content.
Then again, the new content itself get indexed and causes the catalogCounter to be increased, which is usually checked in eTags by plone.app.caching. So it may not be needed for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mauritsvanrees I generally don't cache with eTag. But I think it has a modified date eTag. So it might make sense to change the container modification date when content is added. Perhaps what could be improved is reindexing only the modification date, instead of reindexing all indexes.
Overall I think it is a bad idea to add metadata with length. And it is the wrong approach. |
@jensens I can understand not wanting to add another metadata column. But if we don't add it, then we can't add this feature. We can't do a separate path query for every item in the folder contents listing to find out whether to show a folder icon. (IMO, we don't need the exact number of children, only whether there are 0 or 1+. Then it would be a boolean and literally 2 bytes added to the pickle of the brain, and would only need to be updated when moving from 0 to 1 or vice versa.) I don't personally feel that strongly one way or the other. I think the feature would improve UX, and I doubt the performance impact is significant. But I also won't push for it. |
I really miss a visual difference between containers and non-containers. |
@jensens in addition to what David said a straight path query wouldn't work anyway because you want to know if the page contains other folderish content types, not just images for example. So that's an even more expensive query. And you really don't want to do that once per item in a listing as David said. |
@davisagli Then lets add a bool. And once a thing is considered a folder, I would stick to it, do not recalculate all the time. As said, this is the recipe for a disaster - and given the effect (showing a different icon?) its not worth the danger. |
Any update on this one? Would we want it for Plone 6.1? |
I need to look into this and see if I can (at low cost) just grab the length from the actual btree - it's an attribute already. https://github.com/plone/plone.folder/blob/master/src/plone/folder/nogopip.py sorta does the same thing. Maybe I can make a FakeMetadata. Isn't that what I build plone.app.contentlisting for years ago? Sorry, more questions that answers :) |
@sneridagh I wouldn't rush this one. We can add support for it in volto once the backend is implemented carefully. |
Add numberOfFolderishDocuments catalog metadata to allow UX affordance in folder contents in Volto.