1 ##############################################################################
2 #
3 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
4 #
5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10 # FOR A PARTICULAR PURPOSE
11 #
12 ##############################################################################
13 __doc__='''Simple Tree classes
15 $Id: SimpleTree.py,v 1.1 2002-08-30 08:25:34 richard Exp $'''
16 __version__='$Revision: 1.1 $'[11:-2]
18 from Tree import TreeMaker, TreeNode, b2a
20 class SimpleTreeNode(TreeNode):
21 def branch(self):
22 if self.state == 0:
23 return {'link': None, 'img': ' '}
25 if self.state < 0:
26 setst = 'expand'
27 exnum = self.aq_parent.expansion_number
28 img = 'pl'
29 else:
30 setst = 'collapse'
31 exnum = self.expansion_number
32 img = 'mi'
34 base = self.aq_acquire('baseURL')
35 obid = self.id
36 pre = self.aq_acquire('tree_pre')
38 return {'link': '?%s-setstate=%s,%s,%s#%s' % (pre, setst[0],
39 exnum, obid, obid),
40 'img': '<img src="%s/p_/%s" alt="%s" border="0">' % (base, img, setst)}
43 class SimpleTreeMaker(TreeMaker):
44 '''Generate Simple Trees'''
46 def __init__(self, tree_pre="tree"):
47 self.tree_pre = tree_pre
49 def node(self, object):
50 node = SimpleTreeNode()
51 node.object = object
52 node.id = b2a(self.getId(object))
53 return node
55 def markRoot(self, node):
56 node.tree_pre = self.tree_pre
57 node.baseURL = node.object.REQUEST['BASEPATH1']