[Zope3-checkins] SVN: Zope3/trunk/src/zope/ When I converted layers and skins to interfaces, I got the layer part

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Feb 17 17:33:56 EST 2005


Log message for revision 29198:
  When I converted layers and skins to interfaces, I got the layer part 
  wrong and made layer interfaces extend ILayer. But ILayer is an 
  IInterface, *not* an Interface. Layers should not extend but provide 
  ILayer.
  
  

Changed:
  U   Zope3/trunk/src/zope/app/css/__init__.py
  U   Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
  U   Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
  U   Zope3/trunk/src/zope/app/rotterdam/__init__.py
  U   Zope3/trunk/src/zope/app/zopetop/__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-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/app/css/__init__.py	2005-02-17 22:33:55 UTC (rev 29198)
@@ -15,13 +15,11 @@
 
 $Id$
 """
-
-from zope.publisher.interfaces.browser import ILayer
+from zope.interface import Interface
 from zope.app.rotterdam import Rotterdam
 
 
-
-class layer(ILayer):
+class layer(Interface):
     """A clean ILayer called `zope.app.css.layer` used in `CSS` skin."""
 
 

Modified: Zope3/trunk/src/zope/app/publisher/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2005-02-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/app/publisher/browser/configure.zcml	2005-02-17 22:33:55 UTC (rev 29198)
@@ -2,6 +2,12 @@
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser">
 
+<interface
+  interface="zope.publisher.interfaces.browser.ILayer" />
+
+<interface
+  interface="zope.publisher.interfaces.browser.ISkin" />
+
 <defaultLayer
   type="zope.publisher.interfaces.browser.IBrowserRequest"
   layer="zope.publisher.interfaces.browser.IDefaultBrowserLayer" />

Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2005-02-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py	2005-02-17 22:33:55 UTC (rev 29198)
@@ -17,6 +17,7 @@
 """
 from zope.component.interfaces import IDefaultViewName
 from zope.configuration.exceptions import ConfigurationError
+from zope.interface import Interface, directlyProvides
 from zope.interface.interface import InterfaceClass
 from zope.publisher.interfaces.browser import ILayer, ISkin, IDefaultSkin
 from zope.publisher.interfaces.browser import IBrowserRequest
@@ -45,7 +46,7 @@
 sys.modules['zope.app.skins'] = skins
 
 
-def layer(_context, name=None, interface=None, base=ILayer):
+def layer(_context, name=None, interface=None, base=Interface):
     """Provides a new layer.
 
     >>> class Context(object):
@@ -61,8 +62,8 @@
     >>> iface = context.actions[0]['args'][1]
     >>> iface.getName()
     u'layer1'
-    >>> iface.__bases__
-    (<InterfaceClass zope.publisher.interfaces.ILayer>,)
+    >>> ILayer.providedBy(iface)
+    True
     >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
     True
 
@@ -137,7 +138,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 ILayer:
+    if interface is not None and base is not Interface:
         raise ConfigurationError(
             "You cannot specify the 'interface' and 'base' together.")
 
@@ -172,6 +173,8 @@
         kw = {'info': _context.info}
         )
 
+    directlyProvides(interface, ILayer)
+
     # Register the layer interface as a layer
     _context.action(
         discriminator = ('layer', name),
@@ -196,7 +199,7 @@
     
     >>> context = Context()
     >>> skin(context, u'skin1', layers=[Layer1, Layer2])
-    >>> iface = context.actions[0]['args'][1]
+    >>> iface = context.actions[3]['args'][1]
     >>> iface.getName()
     u'skin1'
     >>> pprint.pprint(iface.__bases__)
@@ -256,6 +259,15 @@
         # InterfaceField can find the layer.
         setattr(skins, name, interface)
         path = 'zope.app.skins'+name
+
+        # Register the layers
+        for layer in layers:
+            _context.action(
+                discriminator = None,
+                callable = provideInterface,
+                args = (layer.getName(), layer, ILayer, _context.info)
+            )    
+
     else:
         path = interface.__module__ + '.' + interface.getName()
 

Modified: Zope3/trunk/src/zope/app/rotterdam/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/__init__.py	2005-02-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/app/rotterdam/__init__.py	2005-02-17 22:33:55 UTC (rev 29198)
@@ -16,10 +16,10 @@
 $Id$
 """
 __docformat__ = "reStructuredText"
+from zope.interface import Interface
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
 
-from zope.publisher.interfaces.browser import ILayer, IDefaultBrowserLayer
-
-class rotterdam(ILayer):
+class rotterdam(Interface):
     """The `rotterdam` layer."""
 
 class Rotterdam(rotterdam, IDefaultBrowserLayer):

Modified: Zope3/trunk/src/zope/app/zopetop/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/zopetop/__init__.py	2005-02-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/app/zopetop/__init__.py	2005-02-17 22:33:55 UTC (rev 29198)
@@ -17,16 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.publisher.interfaces.browser import ILayer
+from zope.interface import Interface
 from zope.app.rotterdam import Rotterdam
 
-class templates(ILayer):
+class templates(Interface):
     """Layer to store all templates."""
 
-class images(ILayer):
+class images(Interface):
     """Layer to store all images."""
 
-class css(ILayer):
+class css(Interface):
     """Layer to store all stylesheets."""
 
 class ZopeTop(templates, images, css, Rotterdam):

Modified: Zope3/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/browser.py	2005-02-17 22:29:58 UTC (rev 29197)
+++ Zope3/trunk/src/zope/publisher/interfaces/browser.py	2005-02-17 22:33:55 UTC (rev 29198)
@@ -15,7 +15,7 @@
 
 $Id$
 """
-from zope.interface import Interface, Attribute
+from zope.interface import Interface, Attribute, directlyProvides
 from zope.interface.interfaces import IInterface
 
 from zope.publisher.interfaces import IPublication
@@ -105,10 +105,10 @@
         """
 
 
-class IDefaultBrowserLayer(ILayer):
+class IDefaultBrowserLayer(Interface):
     """The default layer."""
+directlyProvides(IDefaultBrowserLayer, ILayer)
 
-
 class ISkin(IInterface):
     """A skin is a set of layers."""
 



More information about the Zope3-Checkins mailing list