Update of /cvsroot/webware/Webware/MiddleKit/Core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3496
Modified Files:
Klass.py
Log Message:
Added Klass.descendants() method which returns all descendant klasses of
a Klass.
Index: Klass.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Core/Klass.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** Klass.py 3 Apr 2004 04:01:38 -0000 1.24
--- Klass.py 20 Jul 2004 16:34:37 -0000 1.25
***************
*** 187,190 ****
--- 187,202 ----
self._subklasses.append(klass)
+ def descendants(self, init=1, memo=None):
+ """ Return all descendant klasses of this klass. """
+ if memo is None:
+ memo = {}
+ if memo.has_key(self):
+ return
+ memo[self] = 1
+ for k in self.subklasses():
+ k.descendants(init=0, memo=memo)
+ if init:
+ del memo[self]
+ return memo.keys()
## Accessing attributes ##
|