Em Quinta 27 Abril 2006 18:51, Michele Cella escreveu: > from turbogears import widgets > > def common_widget(): > return widgets.TextField() > > class FooBar(widgets.WidgetsList): > bar = widgets.TextField() > common = common_widget() > foo = widgets.TextField() > key = common_widget() > mouse = common_widget() > > for widget in FooBar(): > print widget.name > > output: > > bar > common > foo > key > mouse > > Rule of thumb of the day: never nest WidgetsList instances. > > This avoids you any sort of problem.
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? 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()) ? Is I can, then it is fine, for now, at least... -- Jorge Godoy <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
