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 @@
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
zope.location.
......
......@@ -27,7 +27,7 @@ def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zope.container',
version = '3.9.2dev',
version = '3.10.0dev',
author='Zope Corporation and Contributors',
author_email='zope-dev@zope.org',
description='Zope Container',
......@@ -40,7 +40,7 @@ setup(name='zope.container',
+ '\n\n' +
read('CHANGES.txt')
),
keywords = "zope3 container",
keywords = "zope container",
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
......@@ -65,8 +65,6 @@ setup(name='zope.container',
extras_require=dict(
test=['zope.copypastemove',
'zope.app.testing',
'zope.app.component',
'zope.app.dependable',
]),
install_requires=['setuptools',
'zope.interface',
......
......@@ -56,13 +56,6 @@
factory=".contained.NameChooser"
/>
<subscriber
zcml:condition="installed zope.app.dependable"
handler=".dependency.CheckDependency"
for="zope.lifecycleevent.interfaces.IObjectRemovedEvent"
trusted="y"
/>
<subscriber
for="zope.location.interfaces.ILocation
zope.lifecycleevent.interfaces.IObjectMovedEvent"
......
......@@ -12,35 +12,6 @@
#
##############################################################################
"""Subscriber function checking dependencies if a removal is performed
on an object having dependencies. It raises an exception if it's the
case.
$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))
# BBB imports
from zope.app.dependable.dependency import exception_msg
from zope.app.dependable.dependency import CheckDependency
##############################################################################
#
# 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