I'll try tomorrow maybe, now I need to get some "paying" job done... :)
What about the __getitem__ for errors, etc? could try to get that  
done too...

Alberto

On 15/03/2006, at 18:19, Michele Cella wrote:

>
> Just a note, I will be offline until tomorrow, if you agree on the
> solution I proposed (make it a list like template_vars) and someone
> wants to implement it (yes, I'm talking with you Alberto, the
> template_vars author :P) it's fine with me.
>
> Ciao
> Michele
>
> Michele Cella wrote:
>> Hi guys,
>>
>> The last (small) polish I think we need to flash out for the  
>> widget API
>> is related to the use of the widgets attribute in CompoundWidgets.
>>
>> Background: actually every children widget of a CompoundWidget should
>> be kept inside self.widgets that's a dictionary, this let's us  
>> prepare
>> some methods to generate a Schema and retrieve css and javascript
>> programmatically.
>>
>> The problem: some times ago Alberto added the ability to use a widget
>> Form in the following way:
>>
>> MyForm(Form):
>>     fields = [list of predefined fields]
>>
>> that's a good and probably expected use by even other people since  
>> you
>> pass fields using the fields parameter, what looks strange is that in
>> __init__ we then copy (a reference in reality) those fields inside  
>> our
>> self.widgets in this way:
>>
>>   self.widgets = fields or self.fields or []
>>
>> this seems a bit strange to me, the right way of doing this thing
>> should be:
>>
>> MyForm(Form):
>>     widgets["fields"] = [list of predefined fields]
>>
>> but this is a bit more difficult to explain and not coherent with the
>> fields parameter you can pass at init.
>>
>> 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.
>>
>> 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.
>>
>> Ciao
>> Michele
>
>
>


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