[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Finally get layers done correctly. LAyers must extend a request type to

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Feb 23 16:46:54 EST 2005


Log message for revision 29266:
  Finally get layers done correctly. LAyers must extend a request type to 
  work correctly with the documentation tools.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/css/__init__.py
  U   Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/rotterdam/__init__.py
  U   Zope3/trunk/src/zope/publisher/interfaces/browser.py

-=-
Modified: Zope3/trunk/src/zope/app/css/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/css/__init__.py	2005-02-23 21:45:17 UTC (rev 29265)
+++ Zope3/trunk/src/zope/app/css/__init__.py	2005-02-23 21:46:47 UTC (rev 29266)
@@ -15,11 +15,11 @@
 
 $Id$
 """
-from zope.interface import Interface
+from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.app.rotterdam import Rotterdam
 
 
-class layer(Interface):
+class layer(IBrowserRequest):
     """A clean ILayer called `zope.app.css.layer` used in `CSS` skin."""
 
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2005-02-23 21:45:17 UTC (rev 29265)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2005-02-23 21:46:47 UTC (rev 29266)
@@ -46,7 +46,7 @@
 sys.modules['zope.app.skins'] = skins
 
 
-def layer(_context, name=None, interface=None, base=Interface):
+def layer(_context, name=None, interface=None, base=IBrowserRequest):
     """Provides a new layer.
 
     >>> class Context(object):
@@ -72,7 +72,7 @@
     Possibility 2: Providing a custom base interface
     ------------------------------------------------
     
-    >>> class BaseLayer(ILayer):
+    >>> class BaseLayer(IBrowserRequest):
     ...     pass
     >>> context = Context()
     >>> layer(context, u'layer1', base=BaseLayer)
@@ -89,7 +89,7 @@
     Possibility 3: Define a Layer just through an Interface
     -------------------------------------------------------
 
-    >>> class layer1(ILayer):
+    >>> class layer1(IBrowserRequest):
     ...     pass
     >>> context = Context()
     >>> layer(context, interface=layer1)
@@ -138,8 +138,14 @@
     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 Interface:
+    if interface and not interface.extends(IBrowserRequest):
         raise ConfigurationError(
+            "The layer interface must extend `IBrowserRequest`.")
+    if base is not IBrowserRequest and not IBrowserRequest.extends(base):
+        raise ConfigurationError(
+            "The base interface must extend `IBRowserRequest`.")
+    if interface is not None and base is not IBrowserRequest:
+        raise ConfigurationError(
             "You cannot specify the 'interface' and 'base' together.")
 
     if interface is None:

Modified: Zope3/trunk/src/zope/app/rotterdam/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/__init__.py	2005-02-23 21:45:17 UTC (rev 29265)
+++ Zope3/trunk/src/zope/app/rotterdam/__init__.py	2005-02-23 21:46:47 UTC (rev 29266)
@@ -16,10 +16,10 @@
 $Id$
 """
 __docformat__ = "reStructuredText"
-from zope.interface import Interface
+from zope.publisher.interfaces.browser import IBrowserRequest
 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
 
-class rotterdam(Interface):
+class rotterdam(IBrowserRequest):
     """The `rotterdam` layer."""
 
 class Rotterdam(rotterdam, IDefaultBrowserLayer):

Modified: Zope3/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/browser.py	2005-02-23 21:45:17 UTC (rev 29265)
+++ Zope3/trunk/src/zope/publisher/interfaces/browser.py	2005-02-23 21:46:47 UTC (rev 29266)
@@ -105,7 +105,7 @@
         """
 
 
-class IDefaultBrowserLayer(Interface):
+class IDefaultBrowserLayer(IBrowserRequest):
     """The default layer."""
 directlyProvides(IDefaultBrowserLayer, ILayer)
 



More information about the Zope3-Checkins mailing list