4teamwork / ftw.globalstatusmessage

3 stars 3 forks source link

Add option to exclude subsites from displaying the message #16

Closed jone closed 10 years ago

jone commented 10 years ago

Adds an option to exclude subsites (objects providing INavigationRoot) from displaying the message. I've taken the exclusion approach because it causes new subsites to be included by default.

When having nested subsites, the nearest parent subsite is checked for whether it is included or excluded.

@hvelarde this should solve #12 , can you take a look at it and test whether it is working how you would expect it?

TODO

// @maethu Closes #12

jone commented 10 years ago

I've broken the portal_registry for older Plone versions (103b6d487b5d202b7b1aab5591da3c5ece5f01c2), because each record needs to be defined in registry.xml again, importing from the interface seems not to work. When defining a choice field in registry.xml, a vocabulary must be provided. A vocabulary factory is not supported in registry.xml.

I'm not sure what to do about this. @maethu can we drop support for older Plone versions? This would make it a lot easier :wink:

hvelarde commented 10 years ago

mmm, I think the implementation is not solving the use case; remember, we want to exclude the main site and include just a subsite.

I think it will be easier to do the following: the new field defines only the folderish objects providing INavigationRoot that will display the message. if the list is empty, the message will be shown site-wide; if the list is not empty, then the message will be shown only on the context of the folderish objects selected.

for instance:

root + subsite 1
     + subsite 2

the vocabulary will list (subsite 1, subsite 2); at first, the field is empty so the message is shown site-wide. if I select subsite 1, then the message will not appear on root, neither on subsite 2, only on subsite 1 and all its subfolders structure.

this way the implementation will be easier and cleaner:

yes, it has limitations, but is better to keep it simple and explain the behavior on the configlet, than make it way to complicated to solve any imaginable use case that is never going to be used.

then we need to think about what will happen when I delete a subsite that is listed on the configlet or when the subsite no longer provides the INavigationRoot interface.

jone commented 10 years ago

I think your use case is covered: you can just select the Plone site for exclusion but not the subsite. The message will then be displayed in the subsite.

With the approach you described above it will not be possible to display the message on the site root and on a subsite but not on another subsite.

hvelarde commented 10 years ago

I can confirm this is not working:

imagem da pgina 2014-05-06 - 09 52 06

jone commented 10 years ago

@hvelarde I assume you have enabled the INavigationRoot interface with manage_interfaces but you did not reindex the object. The vocabulary is based on the catalog index object_provides which needs to be up to date. If you have an AT container you can just edit and save for updating it (this does not work with DX since it is only reindexed when actually something changes).

hvelarde commented 10 years ago

you're right! it's working now :beers:

what about performance?

hvelarde commented 10 years ago

as soon as you merge this I will update the translations and then I would love to see a new release.

thanks!

jone commented 10 years ago

I've squashed my commits a little. I've tested removing an excluded subsite, it does not break the viewlet nor the vocabulary constraint / control panel. Performance: When not activating a message or not excluding any subsites it should be quite fast, when a message is activated and subsites are excluded one catalog query per request is done when rendering the viewlet. The query is {'object_provides': '...INavigationRoot'} which should not have a lot results on normal setups and should be quite fast, I think. We could add a cache on saving the control panel, but I think this is overkill and would only do it when experiencing problems without the cache.

hvelarde commented 10 years ago

great! :beers: