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

I don't agree. The possibility to pass callables that get auto-invoked 
is very convenient for a great deal of use-cases. Of course one could 
come up with other approaches - a common subclass these parameters must 
be inherited from for example. Or some other javaish solution.

But for 98% of the use-cases, passing a callable very easily solves the 
problem.

And all you need to circumvene the automatism is a simple

lamdba: my_function


Additionally, see my other post for a way to create callables for use in 
the templates.

Generally speaking, update_params is *the* central way of performing any 
needed setup before rendering the template.

Diez

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