Jorge Godoy wrote:
>
> But you're supposing that "common_widget" is *one* widget only.  What if it is
> a "list" (I'd write set but we have it in Python as well, so... ;-)) of them?
>

Same applies, you have to deffer the widget creation to when you
effectively use it.
As I said if we want to fix something like this to work I have a pretty
straightforward patch that works, still I'm not sure suggesting to nest
WidgetsList is something we should do, it looks so ugly. :P

> I'll check this and it solves the problem for me in an ugly way -- I'd rather
> have all my widgets inside widgets.WidgetsList derived classes instead of
> mixing functions and classes to write them.  Specially because there are
> cases where the widget alone makes sense and should be usable to build a
> form...  So, can I do, with the above code:
>
> my_form = widgets.TableForm(fields = common_widget())
>

wrap it inside a list:

my_form = widgets.TableForm(fields = [common_widget()])

I can't see the problem, you're just using a single widget so you need
to wrap it in a list, but this is saving you [index] in the WidgetsList
declaraion, or you can also do if you:

def common_widget(in_list=False):
    if in_list:
        return [TextField()]
    else:
        return TextField()

then:

class MyWidgets(WidgetsList):
     name = TextField()
     common = common_widget

my_form = widgets.TableForm(fields = common_widget(True))

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