[Checkins] SVN: zope.app.publisher/trunk/ Finally removed <browser:skin> and <browser:layer> that were marked as deprecated in 2006/02.
Wolfgang Schnerring
wosc at wosc.de
Tue Jan 27 09:01:33 EST 2009
Log message for revision 95192:
Finally removed <browser:skin> and <browser:layer> that were marked as deprecated in 2006/02.
Changed:
U zope.app.publisher/trunk/CHANGES.txt
U zope.app.publisher/trunk/buildout.cfg
U zope.app.publisher/trunk/setup.py
U zope.app.publisher/trunk/src/zope/app/publisher/browser/metaconfigure.py
-=-
Modified: zope.app.publisher/trunk/CHANGES.txt
===================================================================
--- zope.app.publisher/trunk/CHANGES.txt 2009-01-27 13:55:02 UTC (rev 95191)
+++ zope.app.publisher/trunk/CHANGES.txt 2009-01-27 14:01:32 UTC (rev 95192)
@@ -5,7 +5,8 @@
3.5.3 (unreleased)
==================
-- ...
+- Finally removed <browser:skin> and <browser:layer> that were marked as
+ deprecated in 2006/02.
3.5.2 (2008-12-06)
==================
Modified: zope.app.publisher/trunk/buildout.cfg
===================================================================
--- zope.app.publisher/trunk/buildout.cfg 2009-01-27 13:55:02 UTC (rev 95191)
+++ zope.app.publisher/trunk/buildout.cfg 2009-01-27 14:01:32 UTC (rev 95192)
@@ -4,11 +4,11 @@
[test]
recipe = zc.recipe.testrunner
-eggs = zope.app.publisher [test,back35]
+eggs = zope.app.publisher [test]
[coverage-test]
recipe = zc.recipe.testrunner
-eggs = zope.app.publisher [test,back35]
+eggs = zope.app.publisher [test]
defaults = ['--coverage', '../../coverage']
[coverage-report]
Modified: zope.app.publisher/trunk/setup.py
===================================================================
--- zope.app.publisher/trunk/setup.py 2009-01-27 13:55:02 UTC (rev 95191)
+++ zope.app.publisher/trunk/setup.py 2009-01-27 14:01:32 UTC (rev 95192)
@@ -65,8 +65,6 @@
'zope.app.testing',
'zope.app.securitypolicy',
'zope.app.zcmlfiles'],
- 'back35': ['zope.app.skins',
- 'zope.app.layers'],
},
zip_safe = False,
Modified: zope.app.publisher/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- zope.app.publisher/trunk/src/zope/app/publisher/browser/metaconfigure.py 2009-01-27 13:55:02 UTC (rev 95191)
+++ zope.app.publisher/trunk/src/zope/app/publisher/browser/metaconfigure.py 2009-01-27 14:01:32 UTC (rev 95192)
@@ -34,328 +34,7 @@
from zope.app.publisher.browser.i18nresourcemeta import I18nResource
from zope.app.publisher.browser.viewmeta import view
-# BBB 2006/02/18, to be removed after 12 months
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.publisher.interfaces.browser import ILayer
-zope.deprecation.__show__.on()
-# BBB 2006/02/18, to be removed after 12 months
-def layer(_context, name=None, interface=None, base=IBrowserRequest,
- bbb_aware=False):
- """Provides a new layer.
-
- First, let's ignore the warnigns:
-
- >>> showwarning = warnings.showwarning
- >>> warnings.showwarning = lambda *a, **k: None
-
- >>> class Info(object):
- ... file = u'doctest'
- ... line = 1
- ...
- >>> class Context(object):
- ... info = Info()
- ... def __init__(self): self.actions = []
- ... def action(self, **kw): self.actions.append(kw)
-
- Possibility 1: The Old Way
- --------------------------
-
- >>> context = Context()
- >>> layer(context, u'layer1')
- >>> iface = context.actions[0]['args'][1]
- >>> iface.getName()
- 'layer1'
- >>> ILayer.providedBy(iface)
- True
- >>> import sys
- >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
- True
-
- >>> del sys.modules['zope.app.layers'].layer1
-
- Possibility 2: Providing a custom base interface
- ------------------------------------------------
-
- >>> class BaseLayer(IBrowserRequest):
- ... pass
- >>> context = Context()
- >>> layer(context, u'layer1', base=BaseLayer)
- >>> iface = context.actions[0]['args'][1]
- >>> iface.getName()
- 'layer1'
- >>> iface.__bases__
- (<InterfaceClass zope.app.publisher.browser.metaconfigure.BaseLayer>,)
- >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
- True
-
- >>> del sys.modules['zope.app.layers'].layer1
-
- Possibility 3: Define a Layer just through an Interface
- -------------------------------------------------------
-
- >>> class layer1(IBrowserRequest):
- ... pass
- >>> context = Context()
- >>> layer(context, interface=layer1)
- >>> context.actions[0]['args'][1] is layer1
- True
- >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
- False
-
- Possibility 4: Use an Interface and a Name
- ------------------------------------------
-
- >>> context = Context()
- >>> layer(context, name='layer1', interface=layer1)
- >>> context.actions[0]['args'][1] is layer1
- True
- >>> hasattr(sys.modules['zope.app.layers'], 'layer1')
- True
- >>> import pprint
- >>> pprint.pprint([action['discriminator'] for action in context.actions])
- [('interface', 'zope.app.publisher.browser.metaconfigure.layer1'),
- ('layer', 'layer1')]
-
- Here are some disallowed configurations.
-
- >>> context = Context()
- >>> layer(context, 'foo,bar')
- Traceback (most recent call last):
- ...
- TypeError: Commas are not allowed in layer names.
- >>> layer(context)
- Traceback (most recent call last):
- ...
- ConfigurationError: You must specify the 'name' or 'interface' attribute.
- >>> layer(context, base=BaseLayer)
- Traceback (most recent call last):
- ...
- ConfigurationError: You must specify the 'name' or 'interface' attribute.
-
- >>> layer(context, interface=layer1, base=BaseLayer)
- Traceback (most recent call last):
- ...
- ConfigurationError: You cannot specify the 'interface' and 'base' together.
-
- Enabling the warnings again:
-
- >>> warnings.showwarning = showwarning
- """
- from zope.app import layers
- if name is not None and ',' in name:
- raise TypeError("Commas are not allowed in layer names.")
- if name is None and interface is None:
- raise ConfigurationError(
- "You must specify the 'name' or 'interface' attribute.")
- if interface and not interface.extends(IBrowserRequest):
- raise ConfigurationError(
- "The layer interface must extend `IBrowserRequest`.")
- if base is not IBrowserRequest and not base.extends(IBrowserRequest):
- 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:
- if not bbb_aware:
- warnings.warn_explicit(
- 'Creating layers via ZCML has been deprecated. The '
- 'browser:layer directive will be removed in Zope 3.5. Layers '
- 'are now interfaces extending zope.publisher.interfaces.browser'
- '.IBrowserRequest. They do not need further registration.',
- DeprecationWarning, _context.info.file, _context.info.line)
- interface = InterfaceClass(str(name), (base, ),
- __doc__='Layer: %s' %str(name),
- __module__='zope.app.layers')
- # Add the layer to the layers module.
- # Note: We have to do this immediately, so that directives using the
- # InterfaceField can find the layer.
- layers.set(name, interface)
- path = 'zope.app.layers.'+name
- else:
- if not bbb_aware:
- warnings.warn_explicit(
- 'Layer interfaces do not require registration anymore. The '
- 'browser:layer directive will be removed in Zope 3.5.',
- DeprecationWarning, _context.info.file, _context.info.line)
- path = interface.__module__ + '.' + interface.getName()
-
- # If a name was specified, make this layer available under this name.
- # Note that the layer will be still available under its path, since it
- # is an adapter, and the `LayerField` can resolve paths as well.
- if name is None:
- name = path
- else:
- # Make the interface available in the `zope.app.layers` module, so
- # that other directives can find the interface under the name
- # before the CA is setup.
- layers.set(name, interface)
-
- # Register the layer interface as an interface
- _context.action(
- discriminator = ('interface', path),
- callable = provideInterface,
- args = (path, interface),
- kw = {'info': _context.info}
- )
-
- directlyProvides(interface, ILayer)
-
- # Register the layer interface as a layer
- _context.action(
- discriminator = ('layer', name),
- callable = provideInterface,
- args = (name, interface, ILayer, _context.info)
- )
-
-# BBB 2006/02/18, to be removed after 12 months
-def skin(_context, name=None, interface=None, layers=None):
- """Provides a new skin.
-
- First, let's ignore the warnigns:
- >>> showwarning = warnings.showwarning
- >>> warnings.showwarning = lambda *a, **k: None
-
- >>> import pprint
- >>> class Info(object):
- ... file = u'doctest'
- ... line = 1
- ...
- >>> class Context(object):
- ... info = Info()
- ... def __init__(self): self.actions = []
- ... def action(self, **kw): self.actions.append(kw)
-
- >>> class Layer1(ILayer): pass
- >>> class Layer2(ILayer): pass
-
- Possibility 1: The Old Way
- --------------------------
-
- >>> context = Context()
- >>> skin(context, u'skin1', layers=[Layer1, Layer2])
- >>> iface = context.actions[3]['args'][1]
- >>> iface.getName()
- 'skin1'
- >>> pprint.pprint(iface.__bases__)
- (<InterfaceClass zope.app.publisher.browser.metaconfigure.Layer1>,
- <InterfaceClass zope.app.publisher.browser.metaconfigure.Layer2>)
- >>> import sys
- >>> hasattr(sys.modules['zope.app.skins'], 'skin1')
- True
-
- >>> del sys.modules['zope.app.skins'].skin1
-
- Possibility 2: Just specify an interface
- ----------------------------------------
-
- >>> class skin1(Layer1, Layer2):
- ... pass
-
- >>> context = Context()
- >>> skin(context, interface=skin1)
- >>> context.actions[0]['args'][1] is skin1
- True
-
- Possibility 3: Specify an interface and a Name
- ----------------------------------------------
-
- >>> context = Context()
- >>> skin(context, name='skin1', interface=skin1)
- >>> context.actions[0]['args'][1] is skin1
- True
- >>> import pprint
- >>> pprint.pprint([action['discriminator'] for action in context.actions])
- [('skin', 'skin1'),
- ('interface', 'zope.app.publisher.browser.metaconfigure.skin1'),
- ('skin', 'zope.app.publisher.browser.metaconfigure.skin1')]
-
- Here are some disallowed configurations.
-
- >>> context = Context()
- >>> skin(context)
- Traceback (most recent call last):
- ...
- ConfigurationError: You must specify the 'name' or 'interface' attribute.
- >>> skin(context, layers=[Layer1])
- Traceback (most recent call last):
- ...
- ConfigurationError: You must specify the 'name' or 'interface' attribute.
-
- Enabling the warnings again:
- >>> warnings.showwarning = showwarning
- """
- from zope.app import skins
- if name is None and interface is None:
- raise ConfigurationError(
- "You must specify the 'name' or 'interface' attribute.")
-
- if name is not None and layers is not None:
- warnings.warn_explicit(
- 'Creating skins via ZCML has been deprecated. The browser:skin '
- 'directive will be removed in Zope 3.5. Skins are now interfaces '
- 'extending zope.publisher.interfaces.browser.IBrowserRequest. '
- 'They are registered using the \'interface\' directive.',
- DeprecationWarning, _context.info.file, _context.info.line)
- interface = InterfaceClass(str(name), layers,
- __doc__='Skin: %s' %str(name),
- __module__='zope.app.skins')
-
- # Add the layer to the skins module.
- # Note: We have to do this immediately, so that directives using the
- # InterfaceField can find the layer.
- skins.set(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()
- warnings.warn_explicit(
- 'The browser:skin directive has been deprecated and will be '
- 'removed in Zope 3.5. Skins are now simply registered using '
- 'the \'interface\' directive:\n'
- ' <interface\n'
- ' interface="%s"\n'
- ' type="zope.publisher.interfaces.browser.IBrowserSkinType"\n'
- ' name="%s"\n'
- ' />' % (path, name),
- DeprecationWarning, _context.info.file, _context.info.line)
-
- # Register the skin interface as a skin using the passed name.
- if name is not None:
- _context.action(
- discriminator = ('skin', name),
- callable = provideInterface,
- args = (name, interface, IBrowserSkinType, _context.info)
- )
-
- name = path
-
- # Register the skin interface as an interface
- _context.action(
- discriminator = ('interface', path),
- callable = provideInterface,
- args = (path, interface),
- kw = {'info': _context.info}
- )
-
- # Register the skin interface as a skin
- _context.action(
- discriminator = ('skin', name),
- callable = provideInterface,
- args = (name, interface, IBrowserSkinType, _context.info)
- )
-
def setDefaultSkin(name, info=''):
"""Set the default skin.
More information about the Checkins
mailing list