[Zope] ZopeTree cookie patch
Jean Jordaan
jean@upfrontsystems.co.za
Thu, 27 Mar 2003 10:35:32 +0200
This is a multi-part message in MIME format.
--------------000600080804010702040606
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi Philipp
The attached patch fixes it for me. It sets a path for the cookie.
It gets the path either from the 'path' attribute (if root_object
is a TreeObjectWrapper) or from 'getPhysicalPath'. The 'path'
attribute on TreeObjectWrapper is initialised using 'getPhysicalPath'
if it was not passed in.
The patch changes the signature of TreeObjectWrapper.__init__,
and makes assumptions about the use of the 'path' attribute.
--
Jean Jordaan
http://www.upfrontsystems.co.za
--------------000600080804010702040606
Content-Type: text/plain;
name="ZopeTree-cookie-path.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ZopeTree-cookie-path.patch"
diff -ru /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 Thu Mar 27 10:03:14 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 # njj: How is this intended to be used?
+ else:
+ self.path = '/'.join(obj.getPhysicalPath());
self.object = obj
self.id = obj.getId()
self.folderish = obj.isPrincipiaFolderish
diff -ru /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 Thu Mar 27 10:19:41 2003
@@ -103,8 +103,11 @@
def __init__(self, root_object, id_attr='getId', children_attr='objectValues',
request=None, request_variable='tree-expansion'):
tree_expansion = request.get(request_variable, "")
+ # If root_object is a TreeObjectWrapper, it has a path attribute
+ path = getattr(root_object, '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 = []
--------------000600080804010702040606--