Module pyweb :: Class webwidget
[show private | hide private]
[frames | no frames]

Class webwidget

Known Subclasses:
a, abbr, acronym, address, applet, area, b, base, basefont, bdo, big, blockquote, body, br, button, caption, center, cite, code, col, colgroup, del_, dfn, div, em, fieldset, font, form, frameset, h1, h2, h3, h4, h5, h6, head, hr, html, i, iframe, img, input, ins, isindex, kbd, label, legend, li, link, map, meta, notag, object_, ol, optgroup, option, p, param, pre, q, s, samp, script, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, title, tr, tt, u, ul, var

This is the base class for all web widgets
Method Summary
  __init__(self, *content, **kw)
Generic widget constructor.
  __getattr__(self, name)
  __getitem__(self, name)
  __len__(self)
  __nonzero__(self)
  __repr__(self)
  __setattr__(self, attr, val)
  __setitem__(self, name, val)
Used with templates.
  __str__(self)
  add(self, *items, **kw)
Add content to a widget.
  addglobal(self, name, item)
  addnamed(self, name, *item, **kw)
Adds a named item in the scope of the current tag
  attrdump(self)
Returns a space-separated list of the widget's tag attribs
  attrdumpinto(self, bucket)
renders the tag attributes into the bucket
  attrToStdout(self)
Returns a space-separated list of the widget's tag attribs
  dontWrap(self)
Stops this tag from being enclosed in tags
  dump(self)
Writes string fragments to stdout
  join(self, args)
What a weird yet consummately pythonic method! Read on...
  render(self)
Recursively collate all the content, and content within the content, into one array of string fragments
  renderinto(self, bucket)
Writes string fragments into list 'bucket', for later joining.
  set(self, *items)
Replaces widget's contents with given items
  setattr(self, *args, **kw)
Sets attributes of this widget

Class Variable Summary
str delimiter = '\n'
bool notagclose = False

Method Details

__init__(self, *content, **kw)
(Constructor)

Generic widget constructor. Creates a widget, and optionally stores content.

Arguments:
  • any number of content items - strings or nested widgets
Keywords:
  • delimiter - the delimiter between contents of widget, default is newline
  • savein - ref oa another widget into which to store a ref to this widget
  • saveas - name to save this widget
  • template - a tag object, string or filename containing a template
Example:
 table(tr(td("contents of cell",
             savein=parentwidget,
             saveas='thiscell')))
More:
  • Instead of the 'savein' and 'saveas' keywords, you can simply use 'save(widget, name)' as one of the items. For example:
     table(tr(td(save(parentwidget, 'thiscell'),
                 "Contents of cell")))
    

__setitem__(self, name, val)
(Index assignment operator)

Used with templates. Sets a 'variable' within a template

add(self, *items, **kw)

Add content to a widget.

addnamed(self, name, *item, **kw)

Adds a named item in the scope of the current tag

attrdump(self)

Returns a space-separated list of the widget's tag attribs

attrdumpinto(self, bucket)

renders the tag attributes into the bucket

attrToStdout(self)

Returns a space-separated list of the widget's tag attribs

dontWrap(self)

Stops this tag from being enclosed in tags

dump(self)

Writes string fragments to stdout

If opening and closing tags (eg "<p>" and "</p>") are present, encloses all the content within these tags

join(self, args)

What a weird yet consummately pythonic method! Read on...

This method renders out the tag object, and uses that as the separator for a join.

For example:
  • br().join(['Line 1', 'Line 2', 'Line 3']) produces

    Line 1 <br> Line 2 <br> Line 3

render(self)

Recursively collate all the content, and content within the content, into one array of string fragments

renderinto(self, bucket)

Writes string fragments into list 'bucket', for later joining.

If opening and closing tags (eg "<p>" and "</p>") are present, encloses all the content within these tags

set(self, *items)

Replaces widget's contents with given items

setattr(self, *args, **kw)

Sets attributes of this widget

Class Variable Details

delimiter

Type:
str
Value:
'''
'''                                                                    

notagclose

Type:
bool
Value:
False                                                                  

Generated by Epydoc 2.0 on Sat Feb 7 20:08:06 2004 http://epydoc.sf.net