Hi Diez
yes, it works now.  thanks for your help!
Below are the code snippets just in case someone runs into the same problem:

from the controller (root.py):
====================
from tg import tmpl_context as c
from tw.jquery import TreeView

 @expose('helloworld.templates.about')
    def about(self, **kw):
    myTree = TreeView(treeDiv='navTree')
    c.tree = myTree
    mytext =""" <ul>
                        <li class="open"> product12
                            <ul>
                                <li>item1</li>
                                <li>item2</li>
                            </ul>
                        </li>
                        <li class="open"> product34
                            <ul>
                                <li>item3</li>
                                <li>item4</li>
                            </ul>
                        </li>
                </ul>"""
    return dict(mytext=mytext)

template (about.html):
===============

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:py="http://genshi.edgewall.org/";
      xmlns:xi="http://www.w3.org/2001/XInclude";>

  <xi:include href="master.html" />

<head>
  <meta content="text/html; charset=UTF-8" http-equiv="content-type"
py:replace="''"/>
  <title>Learning TurboGears 2.0: Quick guide to the Quickstart
pages.</title>
</head>

<body>
  ${tmpl_context.tree()}
  <div id="navTree">
      <div py:strip="True" py:content="XML(mytext)">
      </div>
  </div>
</body>
</html>

==========================================


On Thu, Nov 12, 2009 at 3:31 PM, Diez B. Roggisch <[email protected]> wrote:

>
> Thang Nguyen schrieb:
> > Hi Diez,
> > thanks for your email.  You're correct I was using an invalid context
> > object.  After fixing the bug, I was able to display the tree properly.
> >
> > I have another question regarding to generating the tree dynamically.
> > Instead of having navTree div defined statically in the template (as in
> > TG tutorial example), I have a python xml string object (mytext) in my
> > controller (root.py).  This string can potentially be
> > created dynamically, but for now i have it predefined.  I pass this
> > string to the template (about.html).  For some reasons, it does not seem
> > to work as the way I expected.   My browser just shows the actual text
> > of "mytext", but not a tree.  Any suggestion for me to try?  Below are
> > code from my root.py and about.html.   Thanks much.
> >
> >   @expose('helloworld.templates.about')
> >     def about(self, **kw):
> >         myTree = TreeView(treeDiv='navTree')
> >         pylons.c.tree = myTree
> >         mytext =""" <ul>
> >                         <li class=\"open\"> product123
>
> And in triple-quotes, you don't need to escape quotes. Also, *don't* use
> pylons-imports, use tg. While this is currently only an alias, that
> might change in the future.
>
> Diez
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to