[ZPT] CVS: Zope/lib/python/ZTUtils - SimpleTree.py:1.2.14.1 Tree.py:1.4.14.1

Martijn Pieters mj@zope.com
Fri, 4 Oct 2002 11:01:38 -0400


Update of /cvs-repository/Zope/lib/python/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv9171/lib/python/ZTUtils

Modified Files:
      Tag: Zope-2_5-branch
	SimpleTree.py Tree.py 
Log Message:
Merge ZTUtils tree changes from Zope 2.6 branch.


=== Zope/lib/python/ZTUtils/SimpleTree.py 1.2 => 1.2.14.1 ===
--- Zope/lib/python/ZTUtils/SimpleTree.py:1.2	Wed Nov 28 10:51:22 2001
+++ Zope/lib/python/ZTUtils/SimpleTree.py	Fri Oct  4 11:01:37 2002
@@ -52,6 +52,9 @@
         node.id = b2a(self.getId(object))
         return node
 
-    def markRoot(self, node):
-        node.tree_pre = self.tree_pre
-        node.baseURL = node.object.REQUEST['BASEPATH1']
+    def tree(self, root, expanded=None, subtree=0):
+        node = TreeMaker.tree(self, root, expanded, subtree)
+        if not subtree:
+            node.tree_pre = self.tree_pre
+            node.baseURL = root.REQUEST['BASEPATH1']
+        return node


=== Zope/lib/python/ZTUtils/Tree.py 1.4 => 1.4.14.1 ===
--- Zope/lib/python/ZTUtils/Tree.py:1.4	Wed Nov 28 10:51:22 2001
+++ Zope/lib/python/ZTUtils/Tree.py	Fri Oct  4 11:01:37 2002
@@ -106,8 +106,6 @@
             node.state = -1 # collapsed
         if not subtree:
             node.depth = 0
-            if hasattr(self, 'markRoot'):
-                self.markRoot(node)
         return node
 
     def node(self, object):
@@ -143,8 +141,8 @@
                            type(0L):1, type(None):1 }.has_key):
     return is_simple(type(ob))
 
-def aqcallback(self, inst, parent, name, value, filter):
-    return filter(self, inst, parent, name, value)
+def aqcallback(self, inst, name, value, filter):
+    return filter(self, inst, name, value)
 
 from binascii import b2a_base64, a2b_base64
 import string
@@ -192,7 +190,7 @@
         dd = last_depth - node.depth + 1
         last_depth = node.depth
         if dd > 0:
-            steps.append('.' * dd)
+            steps.append('_' * dd)
         steps.append(node.id)
         node.expansion_number = n
         n = n + 1
@@ -203,6 +201,9 @@
 
     If nth is an integer, also return the (map, key) pair for the nth entry.
     '''
+    if len(s) > 8192: # Set limit to 8K, to avoid DoS attacks.
+        raise ValueError('Encoded node map too large')
+    
     map = m = {}
     mstack = []
     pop = 0
@@ -210,7 +211,7 @@
     if nth is not None:
         nth_pair = (None, None)
     for step in split(s, ':'):
-        if step[:1] == '.':
+        if step[0] == '_':
             pop = len(step) - 1
             continue
         if pop < 0: