Package genshi :: Package filters :: Module html :: Class HTMLFormFiller

Class HTMLFormFiller

object --+
         |
        HTMLFormFiller

A stream filter that can populate HTML forms from a dictionary of values.

>>> from genshi.input import HTML
>>> html = HTML('''<form>
...   <p><input type="text" name="foo" /></p>
... </form>''')
>>> filler = HTMLFormFiller(data={'foo': 'bar'})
>>> print html | filler
<form>
  <p><input type="text" name="foo" value="bar"/></p>
</form>
Instance Methods
 
__init__(self, name=None, id=None, data=None)
Create the filter.
 
__call__(self, stream)
Apply the filter to the given stream.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, name=None, id=None, data=None)
(Constructor)

 
Create the filter.
Parameters:
  • name - The name of the form that should be populated. If this parameter is given, only forms where the name attribute value matches the parameter are processed.
  • id - The ID of the form that should be populated. If this parameter is given, only forms where the id attribute value matches the parameter are processed.
  • data - The dictionary of form values, where the keys are the names of the form fields, and the values are the values to fill in.
Overrides: object.__init__

__call__(self, stream)
(Call operator)

 
Apply the filter to the given stream.
Parameters:
  • stream - the markup event stream to filter