Skip to content

Commit

Permalink
Always depend on zope.hookable
Browse files Browse the repository at this point in the history
And remove our Python implementation that was added in 2009. The two
have now diverged with new features in zope.hookable.

Since 2012, zope.hookable has had a Python implementation. Now, with
4.2, the C extension is an optional build.
  • Loading branch information
jamadden committed Nov 7, 2017
1 parent 0d94e20 commit 26d2dcc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 130 deletions.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[run]
source = zope.component
omit =
src/zope/component/standalonetests.py
# Runs in a subprocess
src/zope/component/standalonetests.py
# Not used
src/zope/component/hookable.py

[report]
exclude_lines =
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changes
4.4.2 (unreleased)
------------------

- Nothing changed yet.
- Always install ``zope.hookable`` as a dependency (the ``hook``
extra is now empty). ``zope.hookable`` respects the PURE_PYTHON
environment variable, and has an optional C extension.


4.4.1 (2017-09-26)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from setuptools import setup, find_packages

HOOK_REQUIRES = [
'zope.hookable',
]

PERSISTENTREGISTRY_REQUIRES = [
Expand Down Expand Up @@ -99,13 +98,14 @@ def read(*rnames):
tests_require=TESTS_REQUIRE,
install_requires=[
'setuptools',
'zope.interface>=4.1.0',
'zope.interface >= 4.1.0',
'zope.event',
'zope.hookable >= 4.2.0',
],
include_package_data=True,
zip_safe=False,
extras_require={
'hook': HOOK_REQUIRES,
'hook': HOOK_REQUIRES, # BWC
'persistentregistry': PERSISTENTREGISTRY_REQUIRES,
'security': SECURITY_REQUIRES,
'zcml': ZCML_REQUIRES,
Expand Down
9 changes: 3 additions & 6 deletions src/zope/component/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import sys
import types

from zope.hookable import hookable

from zope.interface import Interface
from zope.interface import implementedBy
from zope.interface import providedBy
Expand All @@ -30,12 +32,7 @@
from zope.component._declaration import adapter
from zope.component._declaration import adapts

# Use the C implementation in zope.hookable, if available; fall back
# to our Python version if not.
try:
from zope.hookable import hookable
except ImportError: #pragma NO COVER
from zope.component.hookable import hookable


# getSiteManager() returns a component registry. Although the term
# "site manager" is deprecated in favor of "component registry",
Expand Down
23 changes: 4 additions & 19 deletions src/zope/component/hookable.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" This module supplies a pure-Python version of zope.hookable.hookable.
"""
class hookable(object):
__slots__ = ('__original', '__implementation')

original = property(lambda self: self.__original,)
implementation = property(lambda self: self.__implementation,)

def __init__(self, implementation):
self.__original = self.__implementation = implementation

def sethook(self, newimplementation):
old, self.__implementation = self.__implementation, newimplementation
return old

def reset(self):
self.__implementation = self.__original

def __call__(self, *args, **kw):
return self.__implementation(*args, **kw)
This module is deprecated. Prefer to use zope.hookable.hookable.
"""
from zope.hookable import hookable
hookable = hookable # BWC
99 changes: 0 additions & 99 deletions src/zope/component/tests/test_hookable.py

This file was deleted.

3 changes: 2 additions & 1 deletion src/zope/component/tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Pure-Python hookable tests
"""
Tests for zope.component.security
"""
import unittest

Expand Down

0 comments on commit 26d2dcc

Please sign in to comment.