def set_skin(self):
        '''Set the correct skin on the request

The request that leads to an email going out may be processed on a different
site to the site that the request is for. To handle this the ``emailSkin``
property of the ``DivisionConfiguration`` is looked up. If no skin is
specified then the defaults are used.

:raises: zope.component.interfaces.ComponentLookupError: if the skin cannot
         be found.

.. seealso:: This code was based on the
             :class:`zope.traversal.namespace.skin` class.'''
        # 1. Look up the skin name
        name = self.skin_name
        if not(name):
            return  # Sorry, Dijkstra
        # 2.  Look up the interface with the skin-name
        try:
            skin = getUtility(IBrowserSkinType, name)
        except ComponentLookupError:
            raise LocationError("emailSkin %s" % name)
        # 3.  Apply the skin to the interface using
        #     zope.publisher.skinnable.applySkin
        applySkin(self.request, skin)
Esempio n. 2
0
    def test_render(self):
        from zope.app.onlinehelp.browser import ZPTOnlineHelpTopicView
        from zope.publisher.browser import TestRequest
        from zope.location.interfaces import LocationError
        from zope.app.rotterdam import Rotterdam
        from zope.publisher.skinnable import applySkin

        class Context(object):
            path = os.path.join(os.path.dirname(__file__),
                                'helptopic.pt')
            title = 'title'

        request = TestRequest()
        applySkin(request, Rotterdam)

        # Normally these are used for IZPTOnlineHelpTopic objects,
        # which have a `path` attribute to a custom template file.
        # We're going to use it with `helptopic.pt`, which is a template
        # used for OnlineHelpTopic objects and won't work for us:
        zpt = ZPTOnlineHelpTopicView(Context, request)
        with self.assertRaises(LocationError) as e:
            zpt.renderTopic()
        self.assertEqual(e.exception.args[1], 'topicContent')

        # We have to assign a 'topicContent' to be able to use that template:
        zpt.topicContent = "the topic text"
        zpt.renderTopic()
Esempio n. 3
0
 def traverse(self, name, ignored):
     self.request.shiftNameToApplication()
     try:
         skin = zope.component.getUtility(IBrowserSkinType, name)
     except ComponentLookupError:
         raise LocationError("++skin++%s" % name)
     applySkin(self.request, skin)
     return self.context
Esempio n. 4
0
 def traverse(self, name, ignored):
     self.request.shiftNameToApplication()
     try:
         skin = zope.component.getUtility(IBrowserSkinType, name)
     except ComponentLookupError:
         raise LocationError("++skin++%s" % name)
     applySkin(self.request, skin)
     return self.context