On Sep 7, 12:18 pm, Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> Ben Sizer schrieb:
>
> > Is update_params only called once, then? This would allow me to modify
> > my data based on the flags I passed in, which is one way of doing it.
>
> It's called once after display(), so you have the change to add
> parameters even at the last minute in the display() call.

Ok, so update_params is passed a dictionary which maps parameter names
to their values, and here you get a chance to modify them in place
before display is called.

> Note that any callable parameters that you pass this way are
> automatically called (without any additional arguments) - I think that
> was one of your questions.

That's a pretty horrific design decision. I might have some complex
object that I want to pass in that can be coerced to unicode by Kid
and hence be displayed automatically in a template. Then later I
decide to make it callable (for reasons relevant to its use and
theoretically irrelevant to its presentation) and then who knows what
will happen? If I'm lucky, I get garbage in the HTML output and only
spend an hour or two wondering how this has magically started
happening. If I'm unlucky, that call had side-effects such as altering
my model, which I then have to roll back.

Even so, this 'feature' is not much use to me, because I need to be
able to pass in a function that takes a single parameter, the idea
being that I call it on each element of my data to get a transformed
copy of the data. But display() will call it for me beforehand, with
no parameters, presumably bombing out with an exception.

Oh, except it looks like it'll only do that if you pass in the
callable to display(). If it was just a callable in the Widget's
default params list and doesn't appear in the local params argument,
it doesn't look like it gets called whether you wanted it to or not.

Poor design. I hope the ToscaWidgets people are reading.

> > But is there some way I can call back out to a Widget's methods from
> > the Kid template? Or is my interface with the template limited to
> > whatever is in 'params'?
>
> You can call any methods that you have listed under "params".

If they weren't already called and replaced with their return values,
you mean?

Not complaining at you Christophe, just frustrated at this all being
under-documented and under-tested! Thanks for your help.

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