def cookieTree(self, root_object, default_state=None): '''Make a tree with state stored in a cookie.''' tree_pre = self.tree_pre state_name = '%s-state' % tree_pre set_name = '%s-setstate' % tree_pre req = root_object.REQUEST state = req.get(state_name) if state: setst = req.form.get(set_name) if setst: st, pn, expid = setst.split(',') state, (m, obid) = decodeExpansion(state, int(pn)) if m is None: pass elif st == 'e': if m[obid] is None: m[obid] = {expid: None} else: m[obid][expid] = None elif st == 'c' and m is not state and obid == expid: del m[obid] else: state = decodeExpansion(state) else: state = default_state tree = self.tree(root_object, state) rows = tree.flat() req.RESPONSE.setCookie(state_name, encodeExpansion(rows)) return tree, rows
def cookieTree(self, root_object, default_state=None): '''Make a tree with state stored in a cookie.''' tree_pre = self.tree_pre state_name = '%s-state' % tree_pre set_name = '%s-setstate' % tree_pre req = root_object.REQUEST state = req.get(state_name) if state: setst = req.form.get(set_name) if setst: st, pn, expid = setst.split(',') state, (m, obid) = decodeExpansion(state, int(pn)) if m is None: pass elif st == 'e': if m[obid] is None: m[obid] = {expid: None} else: m[obid][expid] = None elif st == 'c' and m is not state and obid==expid: del m[obid] else: state = decodeExpansion(state) else: state = default_state tree = self.tree(root_object, state) rows = tree.flat() req.RESPONSE.setCookie(state_name, encodeExpansion(rows)) return tree, rows