Tag

This is, IMHO, the ultimate representation of an HTML (or XML) construct.

An HTML tag can be represented by the tag itself, its attributes, and its contents.

It is up to the derived classes to provide the tag by defining the _tag variable at the class level.

Attributes and contents (which we are calling items) can be manipulated using the types of methods that we normally use to manipulate dictionaries and lists.

Attributes and items can be passed in at the time of construction using the keyword parameters and positional parameters, respectively.

The bracket operators ( __setitem__, __getitem__ and __delitem__) refer to either an attribute or an item depending on whether the value in the brackets is a string or an integer.

If the value is an integer, then the operator is being used to index an item. If it is a string, then it refers to an attribute.

Normally, attribute values are quoted and emitted as part of the attribute list of the tag when writeOn() or __str__() is invoked. However, as a special exception, if the value is None, neither the attribute name or value is emitted. This allows you to "turn off" boolean attributes by specifying a value of None.

Methods

__delitem__(self, key)

   def __delitem__(self, key):

__delslice__(self, start, end)

   def __delslice__(self, start, end):

__getitem__(self, key)

   def __getitem__(self, key):

__init__(self, *parms, **kw)

   def __init__(self, *parms, **kw):

__len__(self)

   def __len__(self):

__setitem__(self, key, val)

   def __setitem__(self, key, val):

__str__(self)

   def __str__(self):

_setValue(self, value)

   def _setValue(self, value):

append(self, item)

   def append(self, item):

getValue(self, dict)

   def getValue(self, dict):

If the tag has a "name" attribute, and there is a key in the dictionary dict of this name, this method will assign the value in the dictionary to the value of the Tag.

"Value of the tag" means whatever is appropriate for the tag, usually it means setting the tags "value" attribute, so that is the default behavior. Tags wishing to override this behavior should override the _setValue() method.

The recommended use of this is to easily extract information from a CGIRequest's "query" dictionary.

This method will recurse through all nested html objects.

has_key(self, key)

   def has_key(self, key):

writeOn(self, writeable)

   def writeOn(self, writeable):