Apologies for the long post.

First off, thanks to Christopher Arndt for the following doc:

Templates for using TurboCheetah with TurboGears
   http://trac.turbogears.org/turbogears/wiki/TurboCheetahTemplates

I was able to use it to embed pure XML into an HTML page very quickly.
(I could not find a way to get it to work using Kid.) I wanted to use
the PXTK js library in a gui we are working on and used it as a reason
to go through the JS library packaging screencast. (Thanks for that,
Kevin. Well worth the cost of the DVD )  It worked like a charm. As I
mentioned in a previous post, the system seems to require embedding xml
on the HTML page. While trying to create TG widgets for the
coresponding PXTK widgets I ran across a lot of issues that are most
likely  due to my lack of understanding of Kid. In any case, I turned
to TurboCheetah and I have the results that I want.

Of course, there are some things that I'd like to clean up. Here is the
controller that uses the PXTK widget:
------------------------------------------------------
import logging
import cherrypy
import turbogears
from turbogears import controllers, expose, validate, redirect
from pxtk import Pxtk
from useplex import json
log = logging.getLogger("useplex.controllers")
sample = '''
<px:Box>
   <px:XML id="myxml" xmlns="www.data.com">
      <Company label="Protea">
        <System
icon="/tg_widgets/pxtk/images/icons/22x22/devices/system.png">
          <Home
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder_home.png">
            <Documents>
              <item label="Plex API Reference" />
              <item label="Plex Handbook" />
              <item label="Getting Started" />
            </Documents>
          </Home>
          <Desktop
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/desktop.png" />
          <Internet
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/www.png" />
        </System>
      </Company>
    </px:XML>

    <px:Tree

defaultLeafIcon="/tg_widgets/pxtk/images/icons/22x22/mimetypes/document.png"

folderClosedIcon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder.png"

folderOpenIcon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder_open.png"
       id="EmployeeTrace" width="285px" height="150px"
dataProvider="{myxml}"
    />
</px:Box>
'''
class Root(controllers.RootController):
    @expose(template="cheetah:useplex.templates.plex",)
#    @expose(template="useplex.templates.welcome",)
    def index(self):
        import time
        p = Pxtk(xml_body=sample)
        log.debug("Happy TurboGears Controller Responding For Duty")
        return dict(now=time.ctime(), xml=p.render(), aWidget=p)
------------------------------------------------------

I pass in aWidget, which is enough to trigger the set up of the JS and
CSS entities. However, I don't know how to set up the cheetah template
such that I can invoke the render() method on the widget within the
template. To get around this I simply pass the xml string as well.

Does any one know how to change the template so that I can do something
like ${aWidget.render()} instead of passing in the xml string as well?

Here is my cheetah template:
------------------------------------------------------
#extends useplex.templates.SiteTemplate

#def pagetitle
    <title>Welcome to TurboGears!</title>
#end def

#def pagecontent
<h1>Welcome to TurboGears!</h1>
<p>This page was generated on ${now}</p>
<p>$xml</p>
#end def
------------------------------------------------------
Here is a sample of the generated file so you know that I am trying to
accomplish:
------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <LINK MEDIA="all" HREF="/tg_widgets/pxtk/css/plexiglass.css"
TYPE="text/css" REL="stylesheet">
    <SCRIPT SRC="/tg_widgets/pxtk/javascript/CORE.js"
TYPE="text/javascript"></SCRIPT>
    <SCRIPT TYPE="text/javascript">require('px')</SCRIPT>
    <title>Welcome to TurboGears!</title>
</head>

<body>
<div id="header">
</div>
<div id="pagecontent">
<h1>Welcome to TurboGears!</h1>

<p>This page was generated on Thu Jul 20 13:09:27 2006</p>

<p><xmp  xmlns:px="http://www.plextk.org/2005/pxm"; class="View">
<px:Box>
   <px:XML id="myxml" xmlns="www.data.com">
      <Company label="Protea">
        <System
icon="/tg_widgets/pxtk/images/icons/22x22/devices/system.png">
          <Home
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder_home.png">
            <Documents>
              <item label="Plex API Reference" />
              <item label="Plex Handbook" />
              <item label="Getting Started" />
            </Documents>
          </Home>
          <Desktop
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/desktop.png" />
          <Internet
icon="/tg_widgets/pxtk/images/icons/22x22/filesystems/www.png" />
        </System>
      </Company>
    </px:XML>

    <px:Tree

defaultLeafIcon="/tg_widgets/pxtk/images/icons/22x22/mimetypes/document.png"

folderClosedIcon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder.png"

folderOpenIcon="/tg_widgets/pxtk/images/icons/22x22/filesystems/folder_open.png"
       id="EmployeeTrace" width="285px" height="150px"
dataProvider="{myxml}"
    />
</px:Box>
</xmp></p>

</div>

</body>
</html>
------------------------------------------------------

Rather than use the PXTK generic widget, I'm going to create TG widgets
around each pxtk widget I need. That way I can decouple the data
portion from the widget portion in the <XMP> and make it more flexible.
 
That's the hope any way...

Thanks for bothering to read this.

Nicky


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

Reply via email to