On Tue, 12 Nov 2002 22:34, Chuck Esterbrook wrote:
> - I like Ian's idea of using lower case letters. Faster to type.
> - Instead of a bunch of these:

> class A(TagWriter):
>     def __init__(self, *contents): TagWriter.__init__(self, 'a',
> contents)

> You could go with the much more simple:
> class A(TagWriter): pass
> class ABBR(TagWriter): pass
> And use self.__class__.lower() to get the name of the tag.

That simplifies the code, sure.
But it stops anyone from subclassing the tag classes.

Consider:

        class TDcen(TD):
            def __init__(self, *contents):
                TD.__init__(self, contents)
                TD.readAttr(self, 'align', 'center')
                 
        a = HTML(HEAD(TITLE(TagParm('title'))),
                 BODY(TABLE(attr(cellspacing=2, cellpadding=2, width='100%'),
                            TR(TDcen(TagParm('leftpane')),
                                TDcen(TagParm('rightpane'))))))

        p1 = Tag(P('first para'), P('second para'))
        p2 = Tag('Just some plain text')

        a.dump(title='this page title', leftpane=p1, rightpane=p2)

Here, I've subclassed 'TD' into 'TDcen', which creates a table cell with 
'align=center' already added to the attributes.

> - Or you could use a more generic design like Ian did where you don't
> have to declare the tags at all.

I feel my design is highly generic. Tag objects can be assigned to variables, 
subclassed, and/or referenced within other tag objects.

> Just some thoughts,

Very much appreciated. I have a C background, and am presently struggling to 
unlearn PHP. Relieved to be at last getting some grasp on Python.

Cheers
David



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to