On 4/27/06, Jorge Godoy <[EMAIL PROTECTED]> 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?
Can (or should) it actually be a CompoundWidget?
I'm not really comfortable with a WidgetList being used in this way. A
WidgetList is just a little syntax sugar around a list. What you end
up with is a list of widgets ready to drop into a form.
Going back to your original example:
class CommonWidget(widgets.WidgetsList):
my_common_widget = widgets.SomeField(...)
class UseCommonWidget(widgets.WidgetsList):
one_widget = widgets.OneField(...)
another_widget = widgets.AnotherField(...)
common = CommonWidget()[0]
class UseCommonWidgetAsWell(widgets.WidgetsList):
other_widget = widgets.OtherField(...)
yet_another_widget = widgets.YetAnotherField(...)
common = CommonWidget()[0]
after_common_widget = widgets.AfterCommonField(...)
I see what you're getting at: you essentially want to define a widget
with all of its options once and then use it in different contexts.
While a single widget can be used in many requests, it *is* fairly
tightly bound to its name. The cleaner solution, to me, than nesting
WidgetLists is to subclass the widget that you want to use commonly.
This is untested, but I think it will work:
class MyCommonWidget(widgets.SomeField):
option1 = "foo"
option2 = "bar"
class UseCommonWidget(widgets.WidgetsList):
one_widget = widgets.OneField(...)
another_widget = widgets.AnotherField(...)
common =MyCommonWidget()
class UseCommonWidgetAsWell(widgets.WidgetsList):
other_widget = widgets.OtherField(...)
yet_another_widget = widgets.YetAnotherField(...)
common = MyCommonWidget()
after_common_widget = widgets.AfterCommonField(...)
Kevin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---