Implémentation du put webdav par méthode adhoc (put_upload). Pour l'instant, l'implém...
[Plinn.git] / skins / custom_generic / setup_talkback_tree.py
1 ## Script (Python) "setup_talkback_tree"
2 ##parameters=tree_root, force_expand=None
3 ##title=Standard Tree
4 ##
5 from ZTUtils import SimpleTreeMaker
6
7 tm = SimpleTreeMaker('tb_tree')
8 def getKids(object):
9 return object.talkback.getReplies()
10 tm.setChildAccess(function=getKids)
11
12 newReplyId = context.REQUEST.form.get('new_reply_id', None)
13 if newReplyId :
14 reply = tree_root.talkback.getReply(newReplyId)
15 parents = {}
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 )
19
20 elif force_expand :
21 reply = tree_root.talkback.getReply(force_expand)
22 parents = {}
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 )
26
27 tree, rows = tm.cookieTree(tree_root)
28
29 resp = context.REQUEST.RESPONSE
30 cookieValue = resp.cookies['tb_tree-state']['value']
31 resp.setCookie('tb_tree-state', cookieValue, path = '/')
32
33
34 rows.pop(0)
35 return {'root': tree, 'rows': rows}