I'm trying to write some custom widgets to simplify my site, and
unfortunately this is far more difficult than it needs to be because
the documentation on custom widgets is so bad. Sorry to be so blunt
but it's plain that this side of TG has been neglected, despite how
useful it could potentially be. What documentation there is seems
limited either to pre-existing widgets and their specific parameters,
or focuses entirely on forms (typically also built out of pre-existing
widgets) I've just finished going through pretty much every link at
http://docs.turbogears.org/1.0/Widgets and overall the amount of
useful information communicated is low. I even have The Book, and that
too focuses on the pre-built widgets and forms.

Let me as a general question, then a specific one.

Generally - is there anywhere that actually goes through the widget
specification properly? By this, I mean not yet another walkthrough to
one person's hypothetical use case. TurboGears' documentation is full
of these things and it is very frustrating. It is like being given
directions to a destination from many other parts of the country when
what you actually wanted was a map so that you can find it yourself.
About the best I can find is 
http://www.turbogears.org/1.0/docs/api/turbogears.widgets.base.Widget-class.html,
and even that is too vague to be very useful. "A callable can be
passed and it will be called automatically when sending variables to
the template." It can be passed where? When are 'variables sent' to
the template? What parameters should this callable take? What should
it return?

Specifically - I want to write a widget that outputs some formatted
data. I want to be able to tweak its formatting behaviour by passing
in parameters, which I believe I can do via naming them in the params
list and passing a named parameter to the constructor or to render.
But then how do I call functions from inside the widget so that I can
format data differently? I don't want to have to preformat the data
that I pass to the widget, but instead want to pass a flag to the
widget so that it can call different formatting functions on the data
it's been supplied. It's a presentation issue so the logic for this
should be in the view, not the controller. I can't seem to reference a
widget's member function from within the template so I don't know how
to do this. Perhaps the data needs processing on the way into the
widget, but again, how would I do that given that the data can be
injected at several different points?

Sorry to sound so dissatisfied, but I get this every single time I sit
down to work on TurboGears - 20 minutes of productivity followed by an
hour of fruitless searching through docs and then a post on here.

Ben Sizer.

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