On Sep 7, 11:55 am, Richard Clark <[EMAIL PROTECTED]> wrote:
> The main trick, from your perspective, is the template. You can see
> it's a full kid template and I could have changed the formatting
> depending on a custom or standard variable. You'll notice the use of
> update_params to add the api_server and public_key pieces to the
> parameters, but you can also access any parameters passed in at widget
> creation at the same time.

This is ok for adding extra data, but I don't really want to add extra
data, more to be able to customise how I display existing data based
on a flag or setting.

Example: I have a GridOfNumbers widget, which displays several columns
of numbers. In addition to the numbers, it also takes a display_type
parameter (integer, ranging from 1 to 3) that specifies how I want to
show those numbers. Imagine also I have 3 corresponding functions -
number_as_digits(), number_as_roman_numerals(),
number_as_english_words() - each taking an int and returning a string.
The idea is that the widget filters all output through one of these 3
functions, based on the display_type parameter provided.

The data could be pre-processed in the controller, but this is purely
about presentation, so the controller is the wrong place for this.
This functionality should be in the template, or the widget.

I could put the processing into update_params, but apparently I can't
pass callables in there or they will have been called already! So I
need to reference callables from outside that function's scope.
Perhaps self.some_function(some_data_extracted_from_params) will work,
though I'm not able to test it just yet.

(Aside: does that even work if you're using the 'value' parameter of
the Widget, or only if using one of the named 'params' parameters? It
seemed from the code that you get 1 positional argument to a widget
called value, but that it doesn't get the chance to be updated...)

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