[Checkins] SVN: zope.location/trunk/ Make 'zope.component' dependency optional.
Tres Seaver
cvs-admin at zope.org
Thu Jun 7 15:04:21 UTC 2012
Log message for revision 126659:
Make 'zope.component' dependency optional.
Use the 'component' extra to force its installation, or just require
it directly).
If 'zope.component' is not present, this package defines the 'ISite'
interface itself, and omits adapter registrations from its ZCML.
Changed:
U zope.location/trunk/CHANGES.txt
U zope.location/trunk/setup.py
U zope.location/trunk/src/zope/location/configure.zcml
U zope.location/trunk/src/zope/location/interfaces.py
U zope.location/trunk/src/zope/location/location.py
U zope.location/trunk/src/zope/location/pickling.py
U zope.location/trunk/src/zope/location/tests/test_configure.py
U zope.location/trunk/src/zope/location/tests/test_traversing.py
U zope.location/trunk/src/zope/location/traversing.py
U zope.location/trunk/tox.ini
-=-
Modified: zope.location/trunk/CHANGES.txt
===================================================================
--- zope.location/trunk/CHANGES.txt 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/CHANGES.txt 2012-06-07 15:04:17 UTC (rev 126659)
@@ -5,6 +5,11 @@
4.0.0 (unreleased)
------------------
+- Made ``zope.component`` dependency optional. Use the ``component`` extra
+ to force its installation (or just require it directly). If
+ ``zope.component`` is not present, this package defines the ``ISite``
+ interface itself, and omits adapter registrations from its ZCML.
+
- Added support for PyPy.
- Added support for continuous integration using ``tox`` and ``jenkins``.
Modified: zope.location/trunk/setup.py
===================================================================
--- zope.location/trunk/setup.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/setup.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -59,11 +59,11 @@
install_requires=['setuptools',
'zope.interface',
'zope.schema>=3.6',
- 'zope.component>=3.8',
'zope.proxy>3.3',
],
extras_require={
'zcml': ['zope.configuration'],
+ 'component': ['zope.component>=3.8'],
'testing': [
'nose',
'coverage',
Modified: zope.location/trunk/src/zope/location/configure.zcml
===================================================================
--- zope.location/trunk/src/zope/location/configure.zcml 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/configure.zcml 2012-06-07 15:04:17 UTC (rev 126659)
@@ -1,12 +1,23 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml">
- <include file="meta.zcml" package="zope.component" />
+ <configure zcml:condition="installed zope.component">
- <adapter factory=".location.LocationProxy" />
- <adapter zcml:condition="installed zope.copy"
- factory=".pickling.LocationCopyHook" />
- <adapter factory=".traversing.LocationPhysicallyLocatable" />
- <adapter factory=".traversing.RootPhysicallyLocatable" />
+ <include file="meta.zcml" package="zope.component" />
+ <adapter factory=".location.LocationProxy"
+ for="*" />
+
+ <adapter factory=".traversing.LocationPhysicallyLocatable"
+ for=".interfaces.ILocation" />
+
+ <adapter factory=".traversing.RootPhysicallyLocatable"
+ for=".interfaces.IRoot" />
+
+ <adapter zcml:condition="installed zope.copy"
+ factory=".pickling.LocationCopyHook"
+ for=".interfaces.ILocation" />
+
+ </configure>
+
</configure>
Modified: zope.location/trunk/src/zope/location/interfaces.py
===================================================================
--- zope.location/trunk/src/zope/location/interfaces.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/interfaces.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -19,10 +19,6 @@
from zope.interface import Attribute
from zope.schema import TextLine
-# BBB
-from zope.component.interfaces import IPossibleSite
-from zope.component.interfaces import ISite
-
from zope.location._compat import u
class ILocation(Interface):
@@ -125,3 +121,16 @@
class LocationError(KeyError, LookupError):
"""There is no object for a given location."""
+
+# Soft dependency on zope.component.
+#
+# Also, these interfaces used to be defined here directly, so this provides
+# backwardc-comppatibiltiy
+try:
+ from zope.component.interfaces import ISite
+ from zope.component.interfaces import IPossibleSite # BBB
+except ImportError: #pragma NO COVER
+ class ISite(Interface):
+ pass
+ class IPossibleSite(Interface): # BBB
+ pass
Modified: zope.location/trunk/src/zope/location/location.py
===================================================================
--- zope.location/trunk/src/zope/location/location.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/location.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -15,8 +15,6 @@
"""
__docformat__ = 'restructuredtext'
-from zope.component import adapter
-from zope.interface import Interface
from zope.interface import implementer
from zope.proxy import ProxyBase
from zope.proxy import getProxiedObject
@@ -84,7 +82,6 @@
@implementer(ILocation)
- at adapter(Interface)
class LocationProxy(ProxyBase):
"""Location-object proxy
Modified: zope.location/trunk/src/zope/location/pickling.py
===================================================================
--- zope.location/trunk/src/zope/location/pickling.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/pickling.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -15,9 +15,7 @@
"""
__docformat__ = 'restructuredtext'
-from zope.component import adapter
from zope.interface import implementer
-from zope.location.interfaces import ILocation
from zope.location.location import inside
try:
@@ -27,7 +25,6 @@
"because zope.copy is not available")
- at adapter(ILocation)
@implementer(ICopyHook)
class LocationCopyHook(object):
"""Copy hook to preserve copying referenced objects that are not
Modified: zope.location/trunk/src/zope/location/tests/test_configure.py
===================================================================
--- zope.location/trunk/src/zope/location/tests/test_configure.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/tests/test_configure.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -19,6 +19,12 @@
def test_it(self):
try:
+ import zope.component # no registrations made if not present
+ except ImportError:
+ ADAPTERS_REGISTERED = 0
+ else:
+ ADAPTERS_REGISTERED = 4
+ try:
from zope.configuration.xmlconfig import _clearContext
from zope.configuration.xmlconfig import _getContext
from zope.configuration.xmlconfig import XMLConfig
@@ -31,7 +37,7 @@
XMLConfig('configure.zcml', zope.location)
adapters = ([x for x in context.actions
if x['discriminator'] is not None])
- self.assertEqual(len(adapters), 4)
+ self.assertEqual(len(adapters), ADAPTERS_REGISTERED)
def test_suite():
Modified: zope.location/trunk/src/zope/location/tests/test_traversing.py
===================================================================
--- zope.location/trunk/src/zope/location/tests/test_traversing.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/tests/test_traversing.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -214,7 +214,7 @@
self.assertEqual(proxy.getName(), 'name')
def test_getNearestSite_context_is_site(self):
- from zope.component.interfaces import ISite
+ from zope.location.interfaces import ISite # zope.component, if present
from zope.interface import directlyProvides
class Dummy(object):
pass
@@ -224,7 +224,7 @@
self.assertTrue(proxy.getNearestSite() is context)
def test_getNearestSite_ancestor_is_site(self):
- from zope.component.interfaces import ISite
+ from zope.location.interfaces import ISite # zope.component, if present
from zope.interface import directlyProvides
from zope.location.interfaces import IRoot
class Dummy(object):
Modified: zope.location/trunk/src/zope/location/traversing.py
===================================================================
--- zope.location/trunk/src/zope/location/traversing.py 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/src/zope/location/traversing.py 2012-06-07 15:04:17 UTC (rev 126659)
@@ -15,17 +15,14 @@
"""
__docformat__ = 'restructuredtext'
-from zope.component import adapter
-from zope.component.interfaces import ISite
from zope.interface import implementer
-from zope.location.interfaces import ILocation
from zope.location.interfaces import ILocationInfo
from zope.location.interfaces import IRoot
+from zope.location.interfaces import ISite # zope.component, if present
@implementer(ILocationInfo)
- at adapter(ILocation)
class LocationPhysicallyLocatable(object):
"""Provide location information for location objects
"""
@@ -115,7 +112,6 @@
return self.getRoot()
@implementer(ILocationInfo)
- at adapter(IRoot)
class RootPhysicallyLocatable(object):
"""Provide location information for the root object
@@ -123,8 +119,6 @@
for parents and nearest sites, so we are only working with context
object, knowing that its the root object already.
"""
-
-
def __init__(self, context):
self.context = context
Modified: zope.location/trunk/tox.ini
===================================================================
--- zope.location/trunk/tox.ini 2012-06-07 14:14:08 UTC (rev 126658)
+++ zope.location/trunk/tox.ini 2012-06-07 15:04:17 UTC (rev 126659)
@@ -11,7 +11,6 @@
commands =
python setup.py test -q
deps =
- zope.component>=3.8
zope.configuration
zope.copy
zope.interface
@@ -22,7 +21,6 @@
commands =
jython setup.py test -q
deps =
- zope.component>=3.8
zope.configuration
zope.copy
zope.interface
More information about the checkins
mailing list