Commit 22b2ded0 authored by Hanno Schlichting's avatar Hanno Schlichting

Break testing dependency on zope.app.dependable by moving the code and tests into that package.

parent 0c7c39e3
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
CHANGES CHANGES
======= =======
3.9.2 (Unreleased) 3.10.0 (Unreleased)
------------------ -------------------
- Break testing dependency on zope.app.dependable by moving the code and tests
into that package.
- Import ISite from zope.component after it was moved there from - Import ISite from zope.component after it was moved there from
zope.location. zope.location.
......
...@@ -27,7 +27,7 @@ def read(*rnames): ...@@ -27,7 +27,7 @@ def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read() return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.container', setup(name='zope.container',
version = '3.9.2dev', version = '3.10.0dev',
author='Zope Corporation and Contributors', author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org', author_email='zope-dev@zope.org',
description='Zope Container', description='Zope Container',
...@@ -40,7 +40,7 @@ setup(name='zope.container', ...@@ -40,7 +40,7 @@ setup(name='zope.container',
+ '\n\n' + + '\n\n' +
read('CHANGES.txt') read('CHANGES.txt')
), ),
keywords = "zope3 container", keywords = "zope container",
classifiers = [ classifiers = [
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment', 'Environment :: Web Environment',
...@@ -65,8 +65,6 @@ setup(name='zope.container', ...@@ -65,8 +65,6 @@ setup(name='zope.container',
extras_require=dict( extras_require=dict(
test=['zope.copypastemove', test=['zope.copypastemove',
'zope.app.testing', 'zope.app.testing',
'zope.app.component',
'zope.app.dependable',
]), ]),
install_requires=['setuptools', install_requires=['setuptools',
'zope.interface', 'zope.interface',
......
...@@ -56,13 +56,6 @@ ...@@ -56,13 +56,6 @@
factory=".contained.NameChooser" factory=".contained.NameChooser"
/> />
<subscriber
zcml:condition="installed zope.app.dependable"
handler=".dependency.CheckDependency"
for="zope.lifecycleevent.interfaces.IObjectRemovedEvent"
trusted="y"
/>
<subscriber <subscriber
for="zope.location.interfaces.ILocation for="zope.location.interfaces.ILocation
zope.lifecycleevent.interfaces.IObjectMovedEvent" zope.lifecycleevent.interfaces.IObjectMovedEvent"
......
...@@ -12,35 +12,6 @@ ...@@ -12,35 +12,6 @@
# #
############################################################################## ##############################################################################
"""Subscriber function checking dependencies if a removal is performed # BBB imports
on an object having dependencies. It raises an exception if it's the from zope.app.dependable.dependency import exception_msg
case. from zope.app.dependable.dependency import CheckDependency
$Id$
"""
__docformat__ = 'restructuredtext'
from zope.i18nmessageid import Message
from zope.container.i18n import ZopeMessageFactory as _
from zope.app.dependable.interfaces import IDependable, DependencyError
from zope.location.interfaces import ILocationInfo
exception_msg = _("""
Removal of object (${object}) which has dependents (${dependents})
is not possible !
You must deactivate this object before trying to remove it.
""")
def CheckDependency(event):
object = event.object
dependency = IDependable(object, None)
if dependency is not None:
dependents = dependency.dependents()
if dependents:
mapping = {
"object": ILocationInfo(object).getPath(),
"dependents": ", ".join(dependents)
}
raise DependencyError(Message(exception_msg, mapping=mapping))
##############################################################################
#
# Copyright (c) 2008 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test the CheckDependency event subscriber.
$Id$
"""
import unittest
from zope.interface import implements
from zope.app.dependable.interfaces import IDependable, DependencyError
from zope.lifecycleevent import ObjectRemovedEvent
from zope.container.dependency import CheckDependency
from zope.traversing.interfaces import IPhysicallyLocatable
class DummyObject(object):
implements(IDependable, IPhysicallyLocatable)
def dependents(self):
return ['dependency1', 'dependency2']
def getPath(self):
return '/dummy-object'
class Test(unittest.TestCase):
def testCheckDependency(self):
obj = DummyObject()
parent = object()
event = ObjectRemovedEvent(obj, parent, 'oldName')
self.assertRaises(DependencyError, CheckDependency, event)
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(Test),
))
if __name__=='__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment