How to test/customise if a controlpanel is rendered in Diazo/css

With a certain theme we do quite some reshuffling in diazo where I'd like to know if a control panel page is rendered. This can be the overview-controlpanel or any sub controlpanel. Unfortunately there's not a consistent naming standard for controlpanel views afaik, not in plone 4 until Plone 5.1rc1. Nany are called @@something-controlpanel, but there's also a few something-settings', prefs_install_products_form, dexterity-types usergroup-userprefs, portal_registry and those are just the official ones, not add'ons.

What I've done so far is checking for '-controlpanel' on the body class and patching the LayoutPolicy in plone.app.layout to add -controlpanel if there's something that looks like prefs_ or -settings:

    extra_controlpanels = ('prefs_', '-settings', 'portal_registry', 'dexterity-types')
    if any(cls in body_class for cls in extra_controlpanels):
        body_class += ' -controlpanel'

This has some extra risk on false positives, or a content editor who creates a folder that ends up in section-something.

Another option could be to figure out if a ControlPanelForm from plone.app.controlpanel is used, but how do I check that in the LayoutPolicy, is there something on the request I could check? Or is there something very obvious I'm missing here that I could use?

If we are going to break some compatibilty again in the next major version this is something simple we could put on the todo-list, rename at least every provided controlpanel to something-controlpanel and make that a preferred/required name for add'on controlpanels...

why don't you iterate over the contents of the portal_controlpanel tool?

I could check for every name in the controlpanel actions, but that's rather inefficient as bodyClass is caculated for every request where the main_template is renderered and it increases with every control panel. the actions view name list could be memoized for a certain time, but it's still plan b what I'm doing. It would be less time consuming if the control panel views themselves have a generic key/property to check for.

@fredvd might not be useful for your usecase but there is a body class related to the permission required to view a certain page. So you can perhaps combine that with something else cover all control panel pages.

Robot tests..?