Change zope's classProvides to be a class decorator.

When attempting to import any module that uses
zope.interface.classProvides in Python 3, a TypeError is raised; it
reads:

    TypeError: Class advice impossible in Python3.  Use the @provider
    class decorator instead.

Following the listed advice seems to function in Python 3.
This commit is contained in:
Roy Wellington Ⅳ 2016-02-19 22:08:40 -08:00
parent b6142c13d6
commit e9d981aceb
8 changed files with 10 additions and 10 deletions

View file

@ -10,9 +10,9 @@ from letsencrypt.plugins import common
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
"""Example Authenticator."""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Example Authenticator plugin"
@ -21,9 +21,9 @@ class Authenticator(common.Plugin):
@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin):
"""Example Installer."""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Example Installer plugin"

View file

@ -61,6 +61,7 @@ logger = logging.getLogger(__name__)
# and load()
@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
# pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Apache configurator.
@ -81,7 +82,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
:ivar dict assoc: Mapping between domains and vhosts
"""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Apache Web Server - Alpha"

View file

@ -32,6 +32,7 @@ logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class NginxConfigurator(common.Plugin):
# pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Nginx configurator.
@ -53,7 +54,6 @@ class NginxConfigurator(common.Plugin):
:ivar tup version: version of Nginx
"""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Nginx Web Server - currently doesn't work"

View file

@ -34,8 +34,8 @@ hostname_regex = re.compile(
@zope.interface.implementer(interfaces.IPlugin)
class Plugin(object):
"""Generic plugin."""
# classProvides is not inherited, subclasses must define it on their own
#zope.interface.classProvides(interfaces.IPluginFactory)
# provider is not inherited, subclasses must define it on their own
# @zope.interface.provider(interfaces.IPluginFactory)
def __init__(self, config, name):
self.config = config

View file

@ -24,6 +24,7 @@ logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
"""Manual Authenticator.
@ -35,7 +36,6 @@ class Authenticator(common.Plugin):
.. todo:: Support for `~.challenges.TLSSNI01`.
"""
zope.interface.classProvides(interfaces.IPluginFactory)
hidden = True
description = "Manually configure an HTTP server"

View file

@ -12,9 +12,9 @@ logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IInstaller)
@zope.interface.provider(interfaces.IPluginFactory)
class Installer(common.Plugin):
"""Null installer."""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Null Installer"
hidden = True

View file

@ -136,6 +136,7 @@ def supported_challenges_validator(data):
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
"""Standalone Authenticator.
@ -144,7 +145,6 @@ class Authenticator(common.Plugin):
challenges from the certificate authority. Therefore, it does not
rely on any existing server program.
"""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Automatically use a temporary webserver"

View file

@ -18,9 +18,9 @@ logger = logging.getLogger(__name__)
@zope.interface.implementer(interfaces.IAuthenticator)
@zope.interface.provider(interfaces.IPluginFactory)
class Authenticator(common.Plugin):
"""Webroot Authenticator."""
zope.interface.classProvides(interfaces.IPluginFactory)
description = "Webroot Authenticator"