Hi Michele,

Great idea!  +1

(comments below)

On 15/03/2006, at 17:39, Michele Cella wrote:
> So here is my proposal, make widgets a list like template_vars for a
> form this will mean something like this:
>
> widgets = ["fields", "submit"]
> fields = []
> submit = SubmitButton()
>
> def __init__(self, fields, submit, ...):
>        if fields:
>            self.fields = fields
>        if submit:
>            self.submit = submit
>
> we could even make that automated (like template_vars) but only for
> init so that we are sure everyone is doing the right thing, not sure
> about this last point tough.

I think we *should* make it automatic: 1) for boiler plate reduction.  
2) for consistency 3) for documentation.

This shouldn't be needed at update_data as they can always be fetched  
form the widget if needed.

What we could even do is to wrap them in a proxy that prevented  
__setitem__ so we have another (thin) layer of protection from   
unthreadsafeness (child widgets should not be modified after  
init...), though this might be overkill and certainly not a high  
priority...

>
> this looks pretty nice, well behaving and probably more explicit (to
> external observer we are declaring where our widgets are), the only
> modification we need is for schema generation and retrieve_css,
> retrieve_javascript that should iterate over self.widgets to collect
> the place to look at.
>
> Opinions? this will require a small fix for other CompoundWidget user
> by the way.
> Kevin, what do you think?
>
> Personally I think this is really the last eventual polish needed.

I'm not so sure... I've been thinking lately in the "repeating  
widget" and I think we might need to change error_for, value_for and  
options_for  to pick up values form a list as well as from a dict  
because lists is how repeated widgets'  values/errors are stored by  
unpack_errors/NestedVariables and how options should be stored by us  
to keep the symmetry.

What if instead of error_for("field") we just have error["field"]?  
This means that for repeating widgets we could have error[0], error 
[1]... __setitem__ will do it free for us I believe...

Well, this is another topic, just introducing a "sneak preview" :)

Nice job! :)

Alberto


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to