[Twisted-Python] web widgets

Christopher Armstrong carmstro at twistedmatrix.com
Sun Jan 13 21:53:45 EST 2002

On Sun, 2002-01-13 at 18:29, Sean Riley wrote:
> some observations of web widgets..
> the "page" variable of the Gadget class was confusing to me.. I initially
> assumed that it was an instance of a Page object - rather than a class
> object. Maybe renaming it to something like "pageClass" would be more
> explicit?

Good point. I'll change it, (making sure to keep backwards
compatibility) if no one objects.


> User classes inheriting from both Gadget and Widget seems to be a very
> common pattern - such as all the classes in both twisted.forum.gadgets and
> twisted.metrics.gadgets. This would suggest another class in the framework
> that fills this niche. This could also refactor all the "if isinstance(self,
> widget)" code which is polluting Gadget into this new class. This would
> become a convenient place for users to simply derive classes from.. I don't
> know what to call it - GadgetWidget or WidgetGadget are just too
> meaningless. It is really a renderable collection of widgets.. any ideas?
> WidgetResource? WidgetGadgetResource? GadgetWidgetResource? Wadget? Gidget?
> Watchamacallit?

I've been thinking out loud about just having Gadget subclass Widget. I
think it would probably make things clearer for newbies, and I doubt it
would create any sort of performance problem, so I don't think there's
really a need to create a separate GadgetWidget class. 

If no one objects, I'll make that change in CVS. It won't affect any old
code, I don't think; there'll just be an ambiguous superclass in code
that subclasses both Gadget and Widget.

> attached is a class diagram for web widgets done in dia :)

Diagrams are cool. Thanks. :)

Anyway, please, keep the suggestions/groanings coming. WebWidgets has a
ways to go before it really becomes easy to use, and I think we really
need to put an effort into it (although we should only expect it to be
easy to use for people who are familiar with class programming in Python

                                Chris Armstrong
                         << radix at twistedmatrix.com >>

More information about the Twisted-Python mailing list