[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Container - DependencyChecker.py:1.3.10.1

Marius Gedminas mgedmin@codeworks.lt
Tue, 10 Dec 2002 14:04:59 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Container
In directory cvs.zope.org:/tmp/cvs-serv27553

Modified Files:
      Tag: named-component-configuration-branch
	DependencyChecker.py 
Log Message:
Provide detailed information on dependency errors

=== Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py 1.3 => 1.3.10.1 ===
--- Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py:1.3	Sat Nov 30 13:32:14 2002
+++ Zope3/lib/python/Zope/App/OFS/Container/DependencyChecker.py	Tue Dec 10 14:04:59 2002
@@ -2,14 +2,14 @@
 #
 # Copyright (c) 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (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.
-# 
+#
 ##############################################################################
 """Objects that take care of annotating dublin core meta data times
 
@@ -20,12 +20,13 @@
 from Zope.App.DependencyFramework.Exceptions import DependencyError
 from Zope.Event.ISubscriber import ISubscriber
 from Zope.Proxy.ProxyIntrospection import removeAllProxies
+from Zope.App.Traversing import getPhysicalPathString, locationAsUnicode
 
 class DependencyChecker:
     """Checking dependency  while deleting object
     """
     __implements__ = ISubscriber
-    
+
     def __init__(self):
         pass
 
@@ -33,10 +34,13 @@
         object = removeAllProxies(event.object)
         dependency = queryAdapter(object, IDependable)
         if dependency is not None:
-            if dependency.dependents():
-                raise DependencyError(" Removal of object dependable")
-                
-CheckDependency = DependencyChecker() 
-    
-        
-        
+            dependents = dependency.dependents()
+            if dependents:
+                objectpath = getPhysicalPathString(event.object)
+                dependents = map(locationAsUnicode, dependents)
+                raise DependencyError("Removal of object (%s)"
+                                      " which has dependents (%s)"
+                                      % (objectpath,
+                                         ", ".join(dependents)))
+
+CheckDependency = DependencyChecker()