[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/DependencyFramework - Exception.py:1.2 configure.zcml:1.1 Dependable.py:1.2 IDependable.py:1.3

Jim Fulton jim@zope.com
Mon, 18 Nov 2002 17:25:17 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/DependencyFramework
In directory cvs.zope.org:/tmp/cvs-serv15653/DependencyFramework

Modified Files:
	Dependable.py IDependable.py 
Added Files:
	Exception.py configure.zcml 
Log Message:
Merged the finishing of the dependency framework from the 
Zope3-Bangalore-TTW-Branch.

Dependable is now an adapter for annotatable objects to register and
track dependencies.


=== Zope3/lib/python/Zope/App/DependencyFramework/Exception.py 1.1 => 1.2 ===
--- /dev/null	Mon Nov 18 17:25:17 2002
+++ Zope3/lib/python/Zope/App/DependencyFramework/Exception.py	Mon Nov 18 17:25:16 2002
@@ -0,0 +1,20 @@
+##############################################################################
+#
+# 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.
+# 
+##############################################################################
+"""
+$Id$
+"""
+
+class DependencyError(Exception):
+    """ This object is dependable"""
+    


=== Added File Zope3/lib/python/Zope/App/DependencyFramework/configure.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/zope'>

  <adapter
      factory=".Dependable."
      provides=".IDependable."
      for="Zope.App.OFS.Annotation.IAnnotatable." />


</zopeConfigure>


=== Zope3/lib/python/Zope/App/DependencyFramework/Dependable.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/DependencyFramework/Dependable.py:1.1	Mon Oct 14 07:51:05 2002
+++ Zope3/lib/python/Zope/App/DependencyFramework/Dependable.py	Mon Nov 18 17:25:16 2002
@@ -17,27 +17,35 @@
 
 __metaclass__ = type
 
-from Persistence import Persistent
 from Zope.App.DependencyFramework.IDependable import IDependable
+from Zope.App.OFS.Annotation.IAnnotations \
+     import IAnnotations
+from Zope.ComponentArchitecture import getAdapter
+
+key = 'Zope.App.DependencyFramework.Dependents'
 
 class Dependable:
     __doc__ = IDependable.__doc__
 
     __implements__ =  IDependable
 
-    def __init__(self):
-        self.__dependents = {}
+    def __init__(self, context):
+        self.context = context
+        
 
     def addDependent(self, location):
         "See Zope.App.DependencyFramework.IDependable.IDependable"
-        self.__dependents[location] = 1
-        self._p_changed = 1
+        annotations = getAdapter(self.context, IAnnotations)
+        annotations [key] = annotations.get(key, ()) + (location, )
 
     def removeDependent(self, location):
         "See Zope.App.DependencyFramework.IDependable.IDependable"
-        del self.__dependents[location]
-        self._p_changed = 1
+        annotations = getAdapter(self.context, IAnnotations)
+        annotations[key] = tuple([loc
+                                  for loc in annotations.get(key, ())
+                                  if loc != location])
 
     def dependents(self):
         "See Zope.App.DependencyFramework.IDependable.IDependable"
-        return list(self.__dependents)
+        annotations = getAdapter(self.context, IAnnotations)
+        return annotations.get(key, ())


=== Zope3/lib/python/Zope/App/DependencyFramework/IDependable.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/DependencyFramework/IDependable.py:1.2	Tue Oct 15 03:26:02 2002
+++ Zope3/lib/python/Zope/App/DependencyFramework/IDependable.py	Mon Nov 18 17:25:16 2002
@@ -19,19 +19,22 @@
 
 class IDependable(Interface):
    """Objects that other objects depend on.
+   
+   Note that IDependable will normally be implemented by an adapter.
    """
 
    def addDependent(location):
        """Add a dependency to a dependent object by location
 
-       The location is the physical path to the object.
+       The location is the physical path to the dependent object.
        """
    def removeDependent(location):
        """Remove a dependency with a dependent object by location.
 
-       The location is the physical path to the object.
+       The location is the physical path to the dependent object.
        """
    def dependents():
        """Return a sequence of dependent object locations.
        """
+       
 __doc__ = IDependable.__doc__ + __doc__