[Zope3-checkins] SVN: Zope3/trunk/src/z Added an explicit default layer, which is not a sub interface of IBrowserRequest. This provides two benefits:

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


Log message for revision 28317:
  Added an explicit default layer, which is not a sub interface of IBrowserRequest. This provides two benefits:
  
  - The default layer is not automatically used for browser request if it's not in the current skin.
  
  - The default layer is not necessarily last in order of layer precedence when looking up views, resources, etc.
  
  The impact of this change is on how browser requests are constructed: IDefaultLayer must explicitly be provided by a request in order to pick up default views, resources, etc.

Changed:
  U   Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
  U   Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
  U   Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py
  U   Zope3/trunk/src/zope/app/form/browser/add.py
  U   Zope3/trunk/src/zope/app/form/browser/addwizard.py
  U   Zope3/trunk/src/zope/app/form/browser/editview.py
  U   Zope3/trunk/src/zope/app/form/browser/editwizard.py
  U   Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
  U   Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
  U   Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
  U   Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
  U   Zope3/trunk/src/zope/app/publisher/browser/icon.py
  U   Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
  U   Zope3/trunk/src/zope/app/rotterdam/__init__.py
  U   Zope3/trunk/src/zope/app/tests/functional.py
  U   Zope3/trunk/src/zope/app/tests/ztapi.py
  U   Zope3/trunk/src/zope/app/zopetop/__init__.py
  U   Zope3/trunk/src/zope/publisher/browser.py
  U   Zope3/trunk/src/zope/publisher/interfaces/browser.py
  U   Zope3/trunk/src/zwiki/tests/test_traverser.py

-=-
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -23,6 +23,7 @@
 from zope.interface.interfaces import IMethod, IInterface 
 from zope.proxy import removeAllProxies
 from zope.publisher.interfaces import IRequest
+from zope.publisher.interfaces.browser import ILayer
 from zope.schema.interfaces import IField
 from zope.security.proxy import removeSecurityProxy
 
@@ -443,9 +444,10 @@
             if reg.required and reg.required[0] is not None and \
                    iface not in reg.required:
                 continue
-            # Ignore views
-            if IInterface.providedBy(reg.required[-1]) and \
-                   reg.required[-1].isOrExtends(IRequest):
+            # Ignore views and layers
+            if IInterface.providedBy(reg.required[-1]) and (
+                   reg.required[-1].isOrExtends(IRequest) or
+                   reg.required[-1].isOrExtends(ILayer)):
                 continue
             factory = _getRealFactory(reg.value)
             path = getPythonPath(factory)

Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -90,12 +90,12 @@
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
        'contents.html',
        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
-       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+       <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
       <function handler>,
       ('Adapters',
        'register',
        (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+        <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
        <InterfaceClass zope.interface.Interface>,
        'contents.html',
        <class 'zope.app.publisher.browser.viewmeta.Contents'>,
@@ -108,12 +108,12 @@
        <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
        'index.html',
        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
-       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+       <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
       <function handler>,
       ('Adapters',
        'register',
        (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+        <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
        <InterfaceClass zope.interface.Interface>,
        'index.html',
        <class 'zope.app.publisher.browser.viewmeta.Contents'>,
@@ -151,16 +151,15 @@
       <function provideInterface>,
       ('', <InterfaceClass zope.interface.Interface>)),
      (('view',
-       <InterfaceClass zope.app.container.browser.tests.test_directive.I>,
+       (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
+        <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
        '+',
-       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
-       <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
        <InterfaceClass zope.interface.Interface>),
       <function handler>,
       ('Adapters',
        'register',
        (<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
-        <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>),
+        <InterfaceClass zope.publisher.interfaces.browser.IDefaultLayer>),
        <InterfaceClass zope.interface.Interface>,
        '+',
        <class 'zope.app.publisher.browser.viewmeta.+'>,

Modified: Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -20,8 +20,8 @@
 from zope.app.container.interfaces import IReadContainer
 from zope.app.tests import ztapi
 from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.component.tests.request import Request
 from zope.publisher.interfaces import NotFound
+from zope.publisher.browser import TestRequest
 from zope.interface import implements
 from zope.publisher.interfaces.browser import IBrowserRequest 
 
@@ -58,7 +58,7 @@
         self.foo = self._getContainer()
         foo2 = self._getContainer(Foo=self.foo)
         # Initiate a request
-        self.request = Request(IBrowserRequest, '')
+        self.request = TestRequest()
         # Create the traverser
         self.traverser = self._getTraverser(foo2, self.request)
         # Define a simple view for the container

Modified: Zope3/trunk/src/zope/app/form/browser/add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/add.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/add.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -29,7 +29,7 @@
 from zope.app.form.interfaces import IInputWidget, WidgetsError
 from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.schema.interfaces import ValidationError
 from zope.security.checker import defineChecker, NamesChecker
 from editview import EditView
@@ -165,7 +165,7 @@
                     )
                   )
     if layer is None:
-        layer = IBrowserRequest
+        layer = IDefaultLayer
     
     s = zapi.getGlobalService(zapi.servicenames.Adapters)
     s.register((for_, layer), Interface, name, class_)

Modified: Zope3/trunk/src/zope/app/form/browser/addwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/addwizard.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/addwizard.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -26,7 +26,7 @@
 from zope.app.form.interfaces import WidgetsError, IInputWidget
 from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
 from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.schema.interfaces import ValidationError
 from zope.security.checker import defineChecker, NamesChecker
 from editwizard import EditWizardView, WizardStorage
@@ -134,6 +134,8 @@
                     permission,
                     )
                   )
+    if layer is None:
+        layer = IDefaultLayer
 
     s = zapi.getGlobalService(zapi.servicenames.Adapter)
-    s.register((for_, layer or IBrowserRequest), Interface, name, class_)
+    s.register((for_, layer), Interface, name, class_)

Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editview.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/editview.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -22,7 +22,7 @@
 
 from zope.interface import Interface
 from zope.schema import getFieldNamesInOrder
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.security.checker import defineChecker, NamesChecker
 
 from zope.app import zapi
@@ -147,7 +147,7 @@
                                 "browserDefault", "publishTraverse"),
                                permission))
     if layer is None:
-        layer = IBrowserRequest
+        layer = IDefaultLayer
 
     s = zapi.getGlobalService(zapi.servicenames.Adapters)
     s.register((for_, layer), Interface, name, class_)

Modified: Zope3/trunk/src/zope/app/form/browser/editwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editwizard.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/editwizard.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -17,7 +17,7 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.security.checker import defineChecker, NamesChecker
 
 from zope.app import zapi
@@ -230,7 +230,10 @@
         NamesChecker(("__call__", "__getitem__", "browserDefault"), permission)
         )
 
+    if layer is None:
+        layer = IDefaultLayer
+
     s = zapi.getGlobalService(zapi.servicenames.Adapter)
-    s.register((for_, layer or IBrowserRequest), Interface, name, class_)
+    s.register((for_, layer), Interface, name, class_)
 
 

Modified: Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metaconfigure.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/metaconfigure.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -27,6 +27,7 @@
 from zope.schema import getFieldNamesInOrder
 from zope.app.container.interfaces import IAdding
 from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.app.publisher.browser.menu import menuItemDirective
 
 from zope.app.form import CustomWidgetFactory
@@ -45,7 +46,7 @@
 
     # default basic information
     for_ = None
-    layer = IBrowserRequest
+    layer = IDefaultLayer
     permission = 'zope.Public'
     template = None
     class_ = None

Modified: Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/schemadisplay.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/schemadisplay.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -18,7 +18,7 @@
 __docformat__ = 'restructuredtext'
 
 from zope.interface import Interface
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.schema import getFieldNamesInOrder
 from zope.security.checker import defineChecker, NamesChecker
 
@@ -90,7 +90,7 @@
                                permission))
 
     if layer is None:
-        layer = IBrowserRequest
+        layer = IDefaultLayer
 
     s = zapi.getGlobalService(zapi.servicenames.Adapters)
     s.register((for_, layer), Interface, name, class_)

Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_add.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_add.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -19,7 +19,7 @@
 
 from zope.app.tests import ztapi
 from zope.interface import Interface, implements
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
 from zope.publisher.browser import TestRequest
 from zope.schema import TextLine, accessors
 from zope.component import getView
@@ -155,8 +155,9 @@
         (descriminator, callable, args, kw) = self._context.last_action
 
         self.assertEqual(descriminator,
-                         ('view', IAdding, "addthis", IBrowserRequest,
-                          IBrowserRequest))
+                         ('view', IAdding, 'addthis', IBrowserRequest, 
+                         IDefaultLayer))
+
         self.assertEqual(callable, AddViewFactory)
 
         (name, schema, label, permission, layer, template,
@@ -168,7 +169,7 @@
         self.assertEqual(schema, I)
         self.assertEqual(label, 'Add this')
         self.assertEqual(permission, 'zope.Public')
-        self.assertEqual(layer, IBrowserRequest)
+        self.assertEqual(layer, IDefaultLayer)
         self.assertEqual(template, 'add.pt')
         self.assertEqual(default_template, 'add.pt')
         self.assertEqual(bases, (V, AddView, ))

Modified: Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2004-11-02 16:32:58 UTC (rev 28317)
@@ -2,10 +2,8 @@
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser">
 
-<!-- BBB: We need this layer, so that the old skin declarations don't -->
-<!-- break. It will nto do anything however, since no views are defined for -->
-<!-- this layer. Date: 09/15/2004 -->
-<browser:layer name="default" />
+<browser:layer name="default"
+  interface="zope.publisher.interfaces.browser.IDefaultLayer" />
 
 <content class="zope.publisher.browser.BrowserRequest">
   <allow

Modified: Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -17,7 +17,7 @@
 """
 from zope.configuration.exceptions import ConfigurationError
 from zope.interface import Interface
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
 from zope.security.proxy import Proxy
 from zope.security.checker import CheckerPublic, Checker
 
@@ -34,7 +34,7 @@
     default_allowed_attributes = '__call__'
 
     def __init__(self, _context, name=None, defaultLanguage='en',
-                 layer=None, permission=None):
+                 layer=IDefaultLayer, permission=None):
         self._context = _context
         self.name = name
         self.defaultLanguage = defaultLanguage
@@ -104,7 +104,7 @@
             discriminator = ('i18n-resource', self.name, self.type, self.layer),
             callable = handler,
             args = (zapi.servicenames.Adapters, 'register',
-                    (self.layer or self.type,), Interface, self.name, factory,
+                    (self.layer,), Interface, self.name, factory,
                     self._context.info)
             )
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/icon.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/icon.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/publisher/browser/icon.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -19,7 +19,7 @@
 import re
 
 from zope.interface import Interface
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.configuration.exceptions import ConfigurationError
 
 from zope.app import zapi
@@ -62,7 +62,7 @@
         return IconView(context, request, self.rname, self.alt)
 
 def IconDirective(_context, name, for_, file=None, resource=None,
-                  layer=IBrowserRequest, alt=None):
+                  layer=IDefaultLayer, alt=None):
 
     iname = for_.getName()
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -45,7 +45,7 @@
 sys.modules['zope.app.skins'] = skins
 
 
-def layer(_context, name=None, interface=None, base=IBrowserRequest):
+def layer(_context, name=None, interface=None, base=ILayer):
     """Provides a new layer.
 
     >>> class Context(object):
@@ -62,7 +62,7 @@
     >>> iface.getName()
     u'layer1'
     >>> iface.__bases__
-    (<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,)
+    (<InterfaceClass zope.publisher.interfaces.browser.ILayer>,)
     >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
     True
 
@@ -71,7 +71,7 @@
     Possibility 2: Providing a custom base interface
     ------------------------------------------------
     
-    >>> class BaseLayer(IBrowserRequest):
+    >>> class BaseLayer(ILayer):
     ...     pass
     >>> context = Context()
     >>> layer(context, u'layer1', base=BaseLayer)
@@ -88,7 +88,7 @@
     Possibility 3: Define a Layer just through an Interface
     -------------------------------------------------------
 
-    >>> class layer1(IBrowserRequest):
+    >>> class layer1(ILayer):
     ...     pass
     >>> context = Context()
     >>> layer(context, interface=layer1)
@@ -137,7 +137,7 @@
     if name is None and interface is None: 
         raise ConfigurationError(
             "You must specify the 'name' or 'interface' attribute.")
-    if interface is not None and base is not IBrowserRequest:
+    if interface is not None and base is not ILayer:
         raise ConfigurationError(
             "You cannot specify the 'interface' and 'base' together.")
 
@@ -188,8 +188,8 @@
     ...     def __init__(self): self.actions = []
     ...     def action(self, **kw): self.actions.append(kw)
 
-    >>> class Layer1(IBrowserRequest): pass
-    >>> class Layer2(IBrowserRequest): pass
+    >>> class Layer1(ILayer): pass
+    >>> class Layer2(ILayer): pass
 
     Possibility 1: The Old Way
     --------------------------
@@ -290,12 +290,15 @@
     >>> from zope.interface import directlyProvides
     >>> from zope.app.tests import ztapi
 
-    >>> class Skin1(IBrowserRequest): pass
+    >>> class Skin1: pass
     >>> directlyProvides(Skin1, ISkin)
 
     >>> ztapi.provideUtility(ISkin, Skin1, 'Skin1')
     >>> setDefaultSkin('Skin1')
     >>> adapters = zapi.getService(zapi.servicenames.Adapters)
+
+	Lookup the default skin for a request that has the 
+
     >>> adapters.lookup((IBrowserRequest,), IDefaultSkin, '') is Skin1
     True
     """

Modified: Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -20,6 +20,7 @@
 from zope.configuration.exceptions import ConfigurationError
 from zope.interface import Interface
 from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.security.checker import CheckerPublic, NamesChecker
 
 from zope.app import zapi
@@ -32,7 +33,7 @@
 allowed_names = ('GET', 'HEAD', 'publishTraverse', 'browserDefault',
                  'request', '__call__')
 
-def resource(_context, name, layer=IBrowserRequest, permission='zope.Public',
+def resource(_context, name, layer=IDefaultLayer, permission='zope.Public',
              file=None, image=None, template=None):
 
     if permission == 'zope.Public':
@@ -61,7 +62,7 @@
                 (layer,), Interface, name, factory, _context.info),
         )
 
-def resourceDirectory(_context, name, directory, layer=IBrowserRequest,
+def resourceDirectory(_context, name, directory, layer=IDefaultLayer,
                       permission='zope.Public'):
     if permission == 'zope.Public':
         permission = CheckerPublic

Modified: Zope3/trunk/src/zope/app/rotterdam/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/__init__.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/rotterdam/__init__.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -17,13 +17,14 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import ILayer, IDefaultLayer
 
-class rotterdam(IBrowserRequest):
+class rotterdam(ILayer):
     """The `rotterdam` layer."""
 
-class Rotterdam(rotterdam):
+class Rotterdam(rotterdam, IDefaultLayer):
     """The `Rotterdam` skin.
 
     It is available via `++skin++zope.app.rotterdam.Rotterdam`.
     """
+

Modified: Zope3/trunk/src/zope/app/tests/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/functional.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/tests/functional.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -41,18 +41,23 @@
 import zope.server.interfaces
 from zope.testing import doctest
 
+import zope.app.pluggableauth
+import zope.app.tests.setup
+
+from zope.app import zapi
 from zope.app.debug import Debugger
-import zope.app.pluggableauth
 from zope.app.publication.http import HTTPPublication
 from zope.app.publication.browser import BrowserPublication
 from zope.app.publication.xmlrpc import XMLRPCPublication
 from zope.app.publication.zopepublication import ZopePublication
 from zope.app.publication.http import HTTPPublication
-import zope.app.tests.setup
+from zope.publisher.interfaces.browser import IDefaultLayer, IDefaultSkin
+from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.app.component.hooks import setSite, getSite
 
 HTTPTaskStub = StringIO
 
+
 class ResponseWrapper(object):
     """A wrapper that adds several introspective methods to a response."""
 
@@ -82,6 +87,13 @@
         return getattr(self._response, attr)
 
 
+def _getDefaultSkin():
+    """Returns the current default skin as an interface."""
+    adapters = zapi.getService(zapi.servicenames.Adapters)
+    skin = adapters.lookup((IBrowserRequest,), IDefaultSkin, '')
+    return skin or IDefaultLayer
+
+
 grant_request = (r"""
 POST /@@grant.html HTTP/1.1
 Authorization: Basic Z2xvYmFsbWdyOmdsb2JhbG1ncnB3
@@ -240,6 +252,7 @@
                                environment=environment,
                                basic=basic, form=form,
                                request=BrowserRequest)
+        zope.interface.directlyProvides(request, _getDefaultSkin())
         return request
 
     def __http_cookie(self, path):
@@ -514,7 +527,8 @@
             request_cls = XMLRPCRequest
             publication_cls = XMLRPCPublication
         else:
-            request_cls = BrowserRequest
+            request_cls = type(BrowserRequest.__name__, (BrowserRequest,), {})
+            zope.interface.classImplements(request_cls, _getDefaultSkin())
             publication_cls = BrowserPublication
     else:
         request_cls = HTTPRequest

Modified: Zope3/trunk/src/zope/app/tests/ztapi.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/ztapi.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/tests/ztapi.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -18,6 +18,7 @@
 import zope.interface
 from zope.component.interfaces import IDefaultViewName
 from zope.publisher.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IDefaultLayer
 from zope.app import zapi
 from zope.app.traversing.interfaces import ITraversable
 
@@ -31,7 +32,7 @@
         layer = type
     provideAdapter(for_[0], providing, factory, name, tuple(for_[1:])+(layer,))
 
-def browserView(for_, name, factory, layer=IBrowserRequest,
+def browserView(for_, name, factory, layer=IDefaultLayer,
                 providing=zope.interface.Interface):
     """Define a global browser view
     """
@@ -39,13 +40,13 @@
         raise ValueError("Factory cannot be a list or tuple")
     provideAdapter(for_, providing, factory, name, (layer,))
 
-def browserViewProviding(for_, factory, providing, layer=IBrowserRequest):
+def browserViewProviding(for_, factory, providing, layer=IDefaultLayer):
     """Define a view providing a particular interface."""
     if isinstance(factory, (list, tuple)):
         raise ValueError("Factory cannot be a list or tuple")
     return browserView(for_, '', factory, layer, providing)
 
-def browserResource(name, factory, layer=IBrowserRequest,
+def browserResource(name, factory, layer=IDefaultLayer,
                     providing=zope.interface.Interface):
     """Define a global browser view
     """
@@ -53,7 +54,7 @@
         raise ValueError("Factory cannot be a list or tuple")
     provideAdapter((layer,), providing, factory, name)
 
-def setDefaultViewName(for_, name, layer=None, type=IBrowserRequest):
+def setDefaultViewName(for_, name, layer=IDefaultLayer, type=IBrowserRequest):
     if layer is None:
         layer = type
     s = zapi.getGlobalServices().getService(zapi.servicenames.Adapters)

Modified: Zope3/trunk/src/zope/app/zopetop/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/zopetop/__init__.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/app/zopetop/__init__.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -17,19 +17,19 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.rotterdam import rotterdam
+from zope.publisher.interfaces.browser import ILayer
+from zope.app.rotterdam import Rotterdam
 
-class templates(IBrowserRequest):
+class templates(ILayer):
     """Layer to store all templates."""
 
-class images(IBrowserRequest):
+class images(ILayer):
     """Layer to store all images."""
 
-class css(IBrowserRequest):
+class css(ILayer):
     """Layer to store all stylesheets."""
 
-class ZopeTop(templates, images, css, rotterdam):
+class ZopeTop(templates, images, css, Rotterdam):
     """The `ZopeTop`.
 
     This skin consists of its three specific layers plus the rotterdam layer.

Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/publisher/browser.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -27,7 +27,7 @@
 from zope.interface import implements, directlyProvides
 from zope.i18n.interfaces import IUserPreferredLanguages
 from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.interfaces.browser import IBrowserRequest, IDefaultLayer
 from zope.publisher.interfaces.browser import IBrowserApplicationRequest
 
 from zope.publisher.http import HTTPRequest, HTTPResponse
@@ -624,6 +624,8 @@
 
         if skin is not None:
             directlyProvides(self, skin)
+        else:
+            directlyProvides(self, IDefaultLayer)
 
     def setPrincipal(self, principal):
         # HTTPRequest needs to notify the HTTPTask of the username.

Modified: Zope3/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/browser.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zope/publisher/interfaces/browser.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -108,6 +108,10 @@
     """A layer contains views of similar layout."""
 
 
+class IDefaultLayer(ILayer):
+    """The default layer."""
+
+
 class ISkin(IInterface):
     """A skin is a set of layers."""
 

Modified: Zope3/trunk/src/zwiki/tests/test_traverser.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_traverser.py	2004-11-02 10:38:51 UTC (rev 28316)
+++ Zope3/trunk/src/zwiki/tests/test_traverser.py	2004-11-02 16:32:58 UTC (rev 28317)
@@ -66,7 +66,7 @@
         page2 = WikiPage()
         wiki['FooBar'] = page2
         IWikiPageHierarchy(page2).parents = ('FrontPage',)
-        request = Request(I, '')
+        request = Request(I)
 
         T = WikiPageTraverser(page1, request)
         self.failUnless(
@@ -81,7 +81,7 @@
         page2 = WikiPage()
         wiki['FooBar'] = page2
         IWikiPageHierarchy(page2).parents = ('FrontPage',)
-        request = Request(I, '')
+        request = Request(I)
 
         T = WikiPageTraverser(page1, request)
         ztapi.provideView(IWikiPage, I, Interface, 'viewfoo', View)



More information about the Zope3-Checkins mailing list