1 ## Script (Python) "setup_talkback_tree"
2 ##parameters=tree_root, force_expand=None
5 from ZTUtils
import SimpleTreeMaker
7 tm
= SimpleTreeMaker('tb_tree')
9 return object.talkback
.getReplies()
10 tm
.setChildAccess(function
=getKids
)
12 newReplyId
= context
.REQUEST
.form
.get('new_reply_id', None)
14 reply
= tree_root
.talkback
.getReply(newReplyId
)
16 for p
in reply
.parentsInThread() : parents
[p
.id] = True
17 onBranch
= parents
.has_key
18 tm
.setStateFunction( lambda o
, s
: onBranch(o
.id) and 1 or s
)
21 reply
= tree_root
.talkback
.getReply(force_expand
)
23 for p
in reply
.parentsInThread() : parents
[p
.id] = True
24 onBranch
= parents
.has_key
25 tm
.setStateFunction( lambda o
, s
: onBranch(o
.id) and 2 or s
)
27 tree
, rows
= tm
.cookieTree(tree_root
)
29 resp
= context
.REQUEST
.RESPONSE
30 cookieValue
= resp
.cookies
['tb_tree-state']['value']
31 resp
.setCookie('tb_tree-state', cookieValue
, path
= '/')
35 return {'root': tree
, 'rows': rows
}