[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publication/ Moved the mechanism that associates the default skin with the current browser request out of zopepublication and into the browser request factory.

Garrett Smith garrett at mojave-corp.com
Tue Nov 2 11:41:08 EST 2004


Log message for revision 28319:
  Moved the mechanism that associates the default skin with the current browser request out of zopepublication and into the browser request factory.

Changed:
  U   Zope3/trunk/src/zope/app/publication/httpfactory.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
  U   Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
  U   Zope3/trunk/src/zope/app/publication/zopepublication.py

-=-
Modified: Zope3/trunk/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-11-02 16:39:30 UTC (rev 28318)
+++ Zope3/trunk/src/zope/app/publication/httpfactory.py	2004-11-02 16:41:07 UTC (rev 28319)
@@ -17,13 +17,15 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.interface import implements
+from zope.interface import implements, providedBy
+from zope.interface import directlyProvides, directlyProvidedBy
 from zope.publisher.http import HTTPRequest
 from zope.publisher.browser import BrowserRequest
+from zope.publisher.interfaces.browser import IDefaultSkin, IDefaultLayer
 from zope.publisher.xmlrpc import XMLRPCRequest
 
+from zope.app import zapi
 from zope.app.publication.interfaces import IPublicationRequestFactory
-
 from zope.app.publication.http import HTTPPublication
 from zope.app.publication.browser import BrowserPublication
 from zope.app.publication.xmlrpc import XMLRPCPublication
@@ -52,6 +54,13 @@
             else:
                 request = BrowserRequest(input_stream, output_steam, env)
                 request.setPublication(self._brower)
+                # Set the default skin
+                adapters = zapi.getService(zapi.servicenames.Adapters)
+                skin = adapters.lookup((providedBy(request),), IDefaultSkin, '')
+                if skin is not None:
+                    directlyProvides(request, directlyProvidedBy(request)+skin)
+                else:
+                    directlyProvides(request, IDefaultLayer)
         else:
             request = HTTPRequest(input_stream, output_steam, env)
             request.setPublication(self._http)

Modified: Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py	2004-11-02 16:39:30 UTC (rev 28318)
+++ Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py	2004-11-02 16:41:07 UTC (rev 28319)
@@ -16,18 +16,26 @@
 $Id$
 """
 from unittest import TestCase, TestSuite, main, makeSuite
+
+from StringIO import StringIO
+
+from zope.publisher.browser import BrowserRequest
+from zope.publisher.http import HTTPRequest
+from zope.publisher.xmlrpc import XMLRPCRequest
+from zope.component.interfaces import IAdapterService
+from zope.component.adapter import GlobalAdapterService
+from zope.component.tests.placelesssetup import PlacelessSetup
+
 from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
-from zope.publisher.browser import BrowserRequest
 from zope.app.publication.browser import BrowserPublication
-from zope.publisher.http import HTTPRequest
 from zope.app.publication.http import HTTPPublication
-from zope.publisher.xmlrpc import XMLRPCRequest
 from zope.app.publication.xmlrpc import XMLRPCPublication
-from StringIO import StringIO
+from zope.app.tests import ztapi
 
-class Test(TestCase):
+class Test(PlacelessSetup, TestCase):
 
     def setUp(self):
+        super(Test, self).setUp()
         self.__factory = HTTPPublicationRequestFactory(None)
         self.__env =  {
             'SERVER_URL':         'http://127.0.0.1',

Modified: Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py	2004-11-02 16:39:30 UTC (rev 28318)
+++ Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py	2004-11-02 16:41:07 UTC (rev 28319)
@@ -52,7 +52,7 @@
         # test container traver
         foo = Container()
         c   = Container(foo=foo)
-        req = Request(I, '')
+        req = Request(I)
 
         T = SimpleComponentTraverser(c, req)
 
@@ -63,12 +63,12 @@
         # test getting a view
         foo = Container()
         c   = Container(foo=foo)
-        req = Request(I, '')
+        req = Request(I)
 
         T = SimpleComponentTraverser(c, req)
         ztapi.provideView(None, I, Interface, 'foo', View)
 
-        self.failUnless(T.publishTraverse(req,'foo').__class__ is View)
+        self.failUnless(T.publishTraverse(req, 'foo').__class__ is View)
 
         self.assertRaises(NotFound, T.publishTraverse, req , 'morebar')
 

Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-11-02 16:39:30 UTC (rev 28318)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py	2004-11-02 16:41:07 UTC (rev 28319)
@@ -196,6 +196,7 @@
             pass
 
         ztapi.setDefaultViewName(E1, 'name',
+                                 layer=None,
                                  type=self.presentation_type)
         view_text = 'You had a conflict error'
         ztapi.provideView(E1, self.presentation_type, Interface,
@@ -240,6 +241,7 @@
             pass
 
         ztapi.setDefaultViewName(E2, 'name',
+                                 layer=self.presentation_type,
                                  type=self.presentation_type)
         view_text = 'You had a conflict error'
 

Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-11-02 16:39:30 UTC (rev 28318)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py	2004-11-02 16:41:07 UTC (rev 28319)
@@ -28,11 +28,9 @@
 from zope.security.interfaces import Unauthorized
 from zope.component.exceptions import ComponentLookupError
 from zope.interface import implements, providedBy
-from zope.interface import directlyProvides, directlyProvidedBy
 from zope.publisher.publish import mapply
 from zope.publisher.interfaces import Retry, IExceptionSideEffects
 from zope.publisher.interfaces import IRequest, IPublication
-from zope.publisher.interfaces.browser import IDefaultSkin
 from zope.security.management import newInteraction, endInteraction
 from zope.security.checker import ProxyFactory
 from zope.security.proxy import removeSecurityProxy
@@ -79,12 +77,6 @@
             if p is None:
                 raise Unauthorized # If there's no default principal
 
-        # Set the default skin
-        adapters = zapi.getService(zapi.servicenames.Adapters)
-        skin = adapters.lookup((providedBy(request),), IDefaultSkin, '')
-        if skin is not None:
-            directlyProvides(request, directlyProvidedBy(request)+skin)
-
         request.setPrincipal(p)
         newInteraction(request)
         transaction.begin()



More information about the Zope3-Checkins mailing list