If you want TW to take care of serving your css and js you need to
create JSLink and CSSLink objects that you can add to the widget's "css"
and "javascript" lists.
Example:
Say your application is in a package called "myapp" and the js file
lives inside a directory called "static/javascript" and is called "myjs.js":
myjs = JSLink(
modname = "myapp",
filename = "static/javascript")
Then append this to your grid subclass:
class MyGrid(DataGrid):
javascript = [myjs]
If TW takes care of serving them then the /toscawidgets/resources url
prefix is mandatory (although configurable, there was a thread not long
ago where I explained how to) so TW's middleware knows that it should
intercept the requst.
If you don't want toscawidgets to handle the static resources and their
dependencies you can just include the <script> and <link> tags yourself
in every page that renders them.
>
> I found this blog post with instructions on creating a new widget at
> http://blog.wyattbaldwin.com/2007/3/22/creating-a-google-maps-toscawidget
>
> Is the preferred way to create a widget to just use "paster" and
> create the widget as a separate project from whatever you are working
> on?
Depends if you want to distibute or easily reuse the widget in other
applications. I personally always implement custom widgets inside the
application I'm working on and after they work, get polished and well
tested decouple them, if ever, for reuse.
Alberto
The genshi master template you're using is wrapping resources with
Genshi's ET when rendering them because it expects them to be TG
widgets' with kid templates. However, they're producing genshi Stream
objects since TW already does the conversion so the ET in the template
can't re-convert it. Remove the ET wrapping and that should do it.
This has already happened to enough people that a TW and TG short howto
at docs.turbogears.org is badly needed... my fault :( Though I wouldn't
mind help in this area... :)
FYI, this problem will go away in TG 1.1 since TG widgets will
automatically wrap their output if needed so they can be displayed in
Genshi with no ET-wrapping in the templates.
Alberto