Package web :: Package web :: Module template :: Class TemplateResult
[hide private]
[frames] | no frames]

Class TemplateResult

source code

    object --+        
             |        
          dict --+    
                 |    
     utils.Storage --+
                     |
UserDict.DictMixin --+
                     |
                    TemplateResult

Dictionary like object for storing template output.

A template can specify key-value pairs in the output using `var` statements. Each `var` statement adds a new key to the template output and the main output is stored with key __body__.

>>> d = TemplateResult(__body__='hello, world', x='foo')
>>> d
<TemplateResult: {'__body__': 'hello, world', 'x': 'foo'}>
>>> print d
hello, world
>>> d = TemplateResult()
>>> d.extend([u'hello', u'world'])
>>> d
<TemplateResult: {'__body__': u'helloworld'}>
Instance Methods [hide private]
new empty dictionary

__init__(self, *a, **kw)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__getitem__(self, name)
x[y]
source code
 
__unicode__(self) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code

Inherited from utils.Storage: __delattr__, __getattr__, __setattr__

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values

Inherited from object: __format__, __reduce__, __reduce_ex__, __subclasshook__

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Returns:
new empty dictionary

Overrides: object.__init__
(inherited documentation)

__getitem__(self, name)
(Indexing operator)

source code 

x[y]

Overrides: dict.__getitem__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: UserDict.DictMixin.__repr__