I'm making a tree out of a StructuredTextDocument e.g.:

StructuredTextParagraph(o This is colin's test tree doc., [
    StructuredTextParagraph(    o most salient overall:, [
        StructuredTextParagraph(        x. finish this project. and
journal project., [
StructuredTextParagraph(o and something else   , [

With the following external method:

from ZTUtils import SimpleTreeMaker
import StructuredText

def StTree(container, REQUEST, context):
    treeobj = context.testdocument #this is a CMFDocument

    #Get the EditableBody of a CMFDocument containing structured
    tree_root = StructuredText.Basic(treeobj.EditableBody())
    #Note that if I use a ParsedXML Document, everything works fine!
    #tree_root = context.ParsedXMLTestDoc
    tree_name = 'mytree'
    tm = SimpleTreeMaker(tree_name)

    #Change the child access function so it will work with
    def getKids(object):
        return object.getChildren()

    #note the following hack! (it doesn't work all the way, that is
my problem)
    #if I don't do this an error results.
    tree_root.REQUEST = container.REQUEST
    tree, rows = tm.cookieTree(tree_root)
    return {'root': tree, 'rows': rows}

This code works, in that the first indent levels of the structured
text are returned as the top-level nodes of the tree.

However, clicking on them does not expand the tree.

If I replace the Structured Text tree_root with a ParsedXML Test
document, and comment out the tm.setChildAccess line and the
tree_root.REQUEST hack, a working tree document results.

I think this is a problem with the plain StructuredTextDocument
lacking it's own request object.

Can anyone give me any pointers?

My goal is to create an easy way to make documents that can be
expanded and collapsed like documents in MSWord outline format. If
there's a simpler solution, please let me know!


Colin Leath

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

Reply via email to