[Zope] Custom tpValues for dtml-tree
Randall Kern
randy@teamkern.net
Thu, 30 Nov 2000 19:19:17 -0800
I'm trying to write a method that works with dtml-tree. It works great,
until I try to expand a node :(
Here's what I've got:
class Foo:
__allow_access_to_unprotected_subobjects = 1
def __init__(self, item):
self.title = item.title
self.items = item.items
def tpValues(self):
"tpValues"
r = []
for item in self.items:
foo = Foo(item)
r.append(foo)
return r
class Module(Folder, etc, etc, etc,):
def tree(self):
"used to create a dtml-tree"
r = []
for item in self.items:
foo = Foo(item)
r.append(foo)
class Bar:
__allow_access_to_unprotected_subobjects = 1
def tpValues(self):
"tpValues"
return self.r
b = Bar()
b.r = r
return b
Then from a dtml method inside an instance of Module I have:
<dtml-tree tree>
<dtml-var title>
</dtml-tree>
This works fine for the first page, but once I try to expand an item I get:
Error Type: AttributeError
Error Value: 'tuple' object has no attribute 'append'
Traceback (innermost last):
File /usr/src/Zope-2.2.2-src/lib/python/ZPublisher/Publish.py, line 222,
in publish_module
File /usr/src/Zope-2.2.2-src/lib/python/ZPublisher/Publish.py, line 187,
in publish
File /usr/src/Zope-2.2.2-src/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
(Object: Traversable)
File /usr/src/Zope-2.2.2-src/lib/python/ZPublisher/Publish.py, line 171,
in publish
File /usr/src/Zope-2.2.2-src/lib/python/ZPublisher/mapply.py, line 160, in
mapply
(Object: randy2)
File /usr/src/Zope-2.2.2-src/lib/python/ZPublisher/Publish.py, line 112,
in call_object
(Object: randy2)
File /usr/src/Zope-2.2.2-src/lib/python/OFS/DTMLMethod.py, line 172, in
__call__
(Object: randy2)
File /usr/src/Zope-2.2.2-src/lib/python/DocumentTemplate/DT_String.py,
line 528, in __call__
(Object: randy2)
File /usr/src/Zope-2.2.2-src/lib/python/TreeDisplay/TreeTag.py, line 154,
in render
(Object: forums(orderby='dir'))
File /usr/src/Zope-2.2.2-src/lib/python/TreeDisplay/TreeTag.py, line 237,
in tpRender
File /usr/src/Zope-2.2.2-src/lib/python/TreeDisplay/TreeTag.py, line 566,
in apply_diff
(Info: ([None, ([140975456, []],)], [140974880, 140974088]))
AttributeError: (see above)
I must be missing something simple here... But I haven't been able to find
it.
Thanks for you help,
-Randy
P.S. this is the second time I've tried to become a Zope convert, and
thanks to a lot of help from this list I think I might make it this time.