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')
    >>> editskin_props.getProperty('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::

    >>> editskin_props.getProperty('need_authentication')
    False
    >>> editskin_props.need_authentication = True
    >>> editskin_props.getProperty('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, or accept both::

    >>> editskin_props.getProperty('switch_skin_action')
    ('based on edit URL',)
    >>> editskin_props._setPropValue('switch_skin_action', ('no URL based switching',))
    >>> editskin_props.getProperty('switch_skin_action')
    ('no URL based switching',)
    >>> editskin_props._setPropValue('switch_skin_action', ('based on edit URL', 'no URL based switching'))
    >>> editskin_props.getProperty('switch_skin_action')
    ('based on edit URL', 'no URL based switching')

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'
