Hi Philipp and all Herewith, another patch against ZopeTree-1-1. It corrects a bug in the previous patch, and changes the functionality to allow pre-expanded trees. What the patch does: - TreeObjectWrapper.__init__: signature changed to (self, obj, path=None), making path optional and getting it from obj if not provided. (Breaks backward compatability.) - ZopeTree.__init__: expanded_nodes=[] added as keyword argument, so that the tree may be primed by passing in a list of expanded nodes. If request_variable is on request, the tree has been browsed, and request_variable overrides expanded_nodes. If ZopeTree is passed a TreeObjectWrapper instance, get path from it; otherwise get it using getPhysicalPath. Included path in the cookie which is set, to stop Mozilla from setting multiple cookies at different paths. -- Jean Jordaan http://www.upfrontsystems.co.za diff -u /usr/local/zope/Products/ZopeTree/TreeObjectWrapper.py ZopeTree/TreeObjectWrapper.py --- /usr/local/zope/Products/ZopeTree/TreeObjectWrapper.py Thu Mar 13 10:34:38 2003 +++ ZopeTree/TreeObjectWrapper.py Fri Mar 28 10:46:22 2003 @@ -29,8 +29,11 @@ __allow_access_to_unprotected_subobjects__ = 1 - def __init__(self, path, obj): - self.path = path + def __init__(self, obj, path=None): + if path: + self.path = path + else: + self.path = '/'.join(obj.getPhysicalPath()); self.object = obj self.id = obj.getId() self.folderish = obj.isPrincipiaFolderish @@ -44,7 +47,7 @@ for id in objectIds: path = posix_path_join(self.path, id) obj = getattr(self.object, id) - children.append(TreeObjectWrapper(path, obj)) + children.append(TreeObjectWrapper(obj, path)) return children def getFolderishChildren(self): diff -u /usr/local/zope/Products/ZopeTree/ZopeTree.py ZopeTree/ZopeTree.py --- /usr/local/zope/Products/ZopeTree/ZopeTree.py Thu Mar 27 09:27:54 2003 +++ ZopeTree/ZopeTree.py Fri Mar 28 15:47:24 2003 @@ -100,15 +100,17 @@ __allow_access_to_unprotected_subobjects__ = 1 - def __init__(self, root_object, id_attr='getId', children_attr='objectValues', - request=None, request_variable='tree-expansion'): + def __init__(self, root_object, id_attr='getId', + children_attr='objectValues', request=None, + request_variable='tree-expansion', expanded_nodes=[]): tree_expansion = request.get(request_variable, "") + path = getattr(root_object, 'path', None) + if not path: + path = '/'.join(root_object.getPhysicalPath()) if tree_expansion: - request.RESPONSE.setCookie(request_variable, tree_expansion) # set a cookie right away + request.RESPONSE.setCookie(request_variable, tree_expansion, path=path) # set a cookie right away expanded_nodes = self.decodeTreeExpansion(tree_expansion) - else: - expanded_nodes = [] - + Node.__init__(self, root_object, 0, id_attr, children_attr, expanded_nodes) self.expand()
Hi Jean and all,
Herewith, another patch against ZopeTree-1-1. It corrects a bug in the previous patch, and changes the functionality to allow pre-expanded trees.
Thank you! I will review the patch asap. I am currently at the DZUG meeting, that's why I haven't responded earlier. Phil
participants (2)
-
Jean Jordaan -
Philipp von Weitershausen