Setup of Skin Switching
=======================

For testing purposes we have made a new default skin.  This
entertaining skin is the default for visitors::

    >>> context = portal
    >>> context.getCurrentSkinName()
    'Monty Python Skin'

You can specify a different edit skin in the portal properties::

    >>> from Products.CMFCore.utils import getToolByName
    >>> portal_props = getToolByName(context, 'portal_properties')
    >>> editskin_props = portal_props.get('editskin_switcher')
    >>> edit_skin = editskin_props.getProperty('edit_skin')
    >>> edit_skin
    'Plone Default'
    >>> editskin_props.edit_skin = 'Holy Grail'

We test this by faking traversal::

    >>> from collective.editskinswitcher.tests.utils import TestRequest
    >>> from collective.editskinswitcher.tests.utils import FakeTraversalEvent
    >>> from collective.editskinswitcher.traversal import switch_skin
    >>> request = TestRequest(SERVER_URL='http://edit.domain.org')
    >>> event = FakeTraversalEvent(context, request)
    >>> switch_skin(context, event)
    >>> context.getCurrentSkinName()
    'Holy Grail'

By default we check for urls to see if we should switch to the edit
skin, but we can also check if a person is logged in::

    >>> need_authentication = editskin_props.getProperty('need_authentication')
    >>> need_authentication
    False
    >>> editskin_props.need_authentication = True
    >>> need_authentication = editskin_props.getProperty('need_authentication')
    >>> need_authentication
    True

At this moment a user only gets the edit skin when he visits an edit
url and is authenticated.  We can also only check if they are
authenticated, regardless of the url::

    >>> switch_skin_action = editskin_props.getProperty('switch_skin_action')
    >>> switch_skin_action == 'based on edit URL'
    True
    >>> editskin_props.switch_skin_action = 'no URL based switching'
    >>> switch_skin_action = editskin_props.getProperty('switch_skin_action')
    >>> switch_skin_action == 'based on edit URL'
    False

When we totally remove our property sheet, no errors are thrown, just
no switching is done anymore.

    >>> del portal_props.editskin_switcher
    >>> request = TestRequest(SERVER_URL='http://edit.domain.org')
    >>> event = FakeTraversalEvent(context, request)
    >>> switch_skin(context, event)
    >>> context.getCurrentSkinName()
    'Holy Grail'
