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):
        r = []

        for item in self.items:
            foo = Foo(item)

        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)

        class Bar:
            __allow_access_to_unprotected_subobjects = 1
            def tpValues(self):
                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>

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
    (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
    (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
    (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

Thanks for you help,

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.

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to