def change_skin(event):
    # Skip when registry cannot be found
    try:
        registry = getUtility(IRegistry)
    except ComponentLookupError:
        return

    # Skip global registry
    if not isinstance(registry, LocalRegistry):
        return

    # Skip unset values
    try:
        settings = registry.forInterface(ILocalSkin)
    except KeyError:
        return

    # Find context
    context = getContextFromRequest(event.request)

    # Skip context, which cannot change skin
    if not hasattr(context, 'changeSkin'):
        return

    # Skip edit forms of objects with ILocalSkin-behavior
    if ILocalSkin(context, None) is not None:
        published = event.request.get('PUBLISHED', None)
        form = getattr(published, 'form', None)
        if IEditForm.implementedBy(form):
            return

    # Get the vocabulary to match against
    vocabulary = getUtility(
        IVocabularyFactory,
        name='collective.behavior.localskin.vocabularies.skinnames'
    )(context)

    # Change valid skinname when possible
    if settings.skinname in vocabulary:
        context.changeSkin(settings.skinname)