{"action":"created","issue":{"url":"https://api.github.com/repos/plone/plone.app.theming/issues/61","labels_url":"https://api.github.com/repos/plone/plone.app.theming/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/plone/plone.app.theming/issues/61/comments","events_url":"https://api.github.com/repos/plone/plone.app.theming/issues/61/events","html_url":"https://github.com/plone/plone.app.theming/pull/61","id":90593072,"number":61,"title":"Introduce theming policy API that makes theme switching possible","user":{"login":"gyst","id":122351,"avatar_url":"https://avatars.githubusercontent.com/u/122351?v=3","gravatar_id":"","url":"https://api.github.com/users/gyst","html_url":"https://github.com/gyst","followers_url":"https://api.github.com/users/gyst/followers","following_url":"https://api.github.com/users/gyst/following{/other_user}","gists_url":"https://api.github.com/users/gyst/gists{/gist_id}","starred_url":"https://api.github.com/users/gyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyst/subscriptions","organizations_url":"https://api.github.com/users/gyst/orgs","repos_url":"https://api.github.com/users/gyst/repos","events_url":"https://api.github.com/users/gyst/events{/privacy}","received_events_url":"https://api.github.com/users/gyst/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/plone/plone.app.theming/labels/pr%20p5.0","name":"pr p5.0","color":"f7f7f7"},{"url":"https://api.github.com/repos/plone/plone.app.theming/labels/pr%20review","name":"pr review","color":"fbca04"},{"url":"https://api.github.com/repos/plone/plone.app.theming/labels/pr%20testing","name":"pr testing","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-06-24T07:25:40Z","updated_at":"2015-07-09T14:01:08Z","closed_at":"2015-07-09T14:01:08Z","pull_request":{"url":"https://api.github.com/repos/plone/plone.app.theming/pulls/61","html_url":"https://github.com/plone/plone.app.theming/pull/61","diff_url":"https://github.com/plone/plone.app.theming/pull/61.diff","patch_url":"https://github.com/plone/plone.app.theming/pull/61.patch"},"body":"If you google for \"plone theme switching\" you get ~ 41.000 results. It was a core feature in Plone in the 2.x series and well supported until Plone4 with collective.themeswitcher. However, changes introduced in the run-up to Plone5 have made theme switching impossible. I've found multiple partially overlapping theme caching implementations in p.a.theming that all hardcode the assumption that there is only one theme. Additionally, Products.CMFPlone messes with one of those caches as well (yuk), for which I will issue a separate pull request if this p.a.theming pull is accepted. All of this is hardcoded in such a way that it cannot be reached by overrides or even monkey patches.\r\n\r\nThe full scope of this pull request is as follows:\r\n- This PR consolidates all theme choosing decisions into a policy facade.\r\n- All existing API entry points relating to this are mapped to the new policy facade in a backward-compatible way.\r\n- The policy framework here does *not* introduce theme switching. That's out of scope. It merely provides a backward- and forward-compatible foundation for doing theme switching outside of core.\r\n- The policy framework introduced works as a request adapter that can be easily swapped by integrators using normal configure.zcml registrations bound to a browser layer, not even requiring an overrides.zcml.\r\n- The policy maintains a single cache manager that supports multiple theme caches per site. Instead of using a _v_volatile it uses a class static to store the cache manager. This is needed because a _v_volatile introduces CSRF write-on-read errors if you actually start using theme switching outside of core. This has a slight performance impact in that the theme needs to be compiled once per Plone instance start, instead of just once per site.\r\n\r\nOutside of this PR you can see how it makes theme switching possible in the Plone Intranet themeswitcher implementation.\r\n- documentation: http://docs.ploneintranet.org/development/components/themeswitcher.html\r\n- code: https://github.com/ploneintranet/ploneintranet/tree/master/src/ploneintranet/themeswitcher\r\n\r\nNote that ploneintranet.themeswitcher is a separate package. It has it's own configure.zcml, it's own generic setup and it's own test suite. It can be easily factored out of ploneintranet and I'm happy to support that if there's an interest. For now it just implements the minimal set we need for Plone Intranet - I'm not sure whether it makes sense to support CMF skin switching etc in a Plone5 world and there would need to be some extra discussion I guess to see whether/how it makes sense to support other collective.themeswitcher features.\r\n\r\nFor theme switching to actually work, CMFPlone needs to stop messing around with theme caching internals. That will become a separate pull request.\r\nhttps://github.com/ploneintranet/Products.CMFPlone/commit/815044838d7a8732ff69d740067d3ab2e8f39ae0\r\nSince that change depends on the new policy adapter being available it only makes sense to issue a CMFPlone pull request once this p.a.theming pull has been merged."},"comment":{"url":"https://api.github.com/repos/plone/plone.app.theming/issues/comments/119987689","html_url":"https://github.com/plone/plone.app.theming/pull/61#issuecomment-119987689","issue_url":"https://api.github.com/repos/plone/plone.app.theming/issues/61","id":119987689,"user":{"login":"gyst","id":122351,"avatar_url":"https://avatars.githubusercontent.com/u/122351?v=3","gravatar_id":"","url":"https://api.github.com/users/gyst","html_url":"https://github.com/gyst","followers_url":"https://api.github.com/users/gyst/followers","following_url":"https://api.github.com/users/gyst/following{/other_user}","gists_url":"https://api.github.com/users/gyst/gists{/gist_id}","starred_url":"https://api.github.com/users/gyst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyst/subscriptions","organizations_url":"https://api.github.com/users/gyst/orgs","repos_url":"https://api.github.com/users/gyst/repos","events_url":"https://api.github.com/users/gyst/events{/privacy}","received_events_url":"https://api.github.com/users/gyst/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T14:01:08Z","updated_at":"2015-07-09T14:01:08Z","body":"Thanks for the merge. I pushed and updated changelog directly to master.\r\nHave now opened follow-up PR for CMFPlone:\r\nhttps://github.com/plone/Products.CMFPlone/pull/667"}}