web2py.gluon.html.XML

Package web2py :: Package gluon :: Module html :: Class XML |
[hide private]
[frames] | no frames]

# Class XML

source code

      object --+
               |
    XmlComponent --+
                   |
                  XML

use it to wrap a string that contains XML/HTML so that it will not be escaped by the template

example:

    >>> XML('<h1>Hello</h1>').xml()
    '<h1>Hello</h1>'

Instance Methods | [hide private]
__init__(self, text, sanitize=True, permitted_tags=`[``'``a``'``,` `'``b``'``,` `'``blockquote``'``,` `'``br/``'``,` `'``i``'``,` `'``li``'``,` `'``ol``'``,` `'``ul``'``,` `'``p``'``,` `'``c``...`, allowed_attributes=`{``'``a``'``:` `[``'``href``'``,` `'``title``'``]``,` `'``blockquote``'``:` `[``'``type``'``]``,` `'``img``'``:` `[``'``src``'``...`) :param text: the XML text :param sanitize: sanitize text using the permitted tags and allowed attributes (default False) :param permitted_tags: list of permitted tags (default: simple list of tags) :param allowed_attributes: dictionary of allowed attributed (default for A, IMG and BlockQuote). | source code
xml(self) | source code
__str__(self) str(x) | source code
__add__(self, other) | source code
__radd__(self, other) | source code
__cmp__(self, other) | source code
__hash__(self) hash(x) | source code
__getattr__(self, name) | source code
__getitem__(self, i) | source code
__getslice__(self, i, j) | source code
__iter__(self) | source code
__len__(self) | source code
flatten(self, render=global_settings.applications_parent) return the text stored by the XML object rendered by the render function | source code
elements(self, *args, **kargs) to be considered experimental since the behavior of this method is questionable another options could be TAG(self.text).elements(*args,**kargs) | source code
Inherited from `object`: `__delattr__`, `__getattribute__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, text, sanitize=True, permitted_tags=`[``'``a``'``,` `'``b``'``,` `'``blockquote``'``,` `'``br/``'``,` `'``i``'``,` `'``li``'``,` `'``ol``'``,` `'``ul``'``,` `'``p``'``,` `'``c``...`, allowed_attributes=`{``'``a``'``:` `[``'``href``'``,` `'``title``'``]``,` `'``blockquote``'``:` `[``'``type``'``]``,` `'``img``'``:` `[``'``src``'``...`) (Constructor) | source code
    :param text: the XML text
    :param sanitize: sanitize text using the permitted tags and allowed
        attributes (default False)
    :param permitted_tags: list of permitted tags (default: simple list of
        tags)
    :param allowed_attributes: dictionary of allowed attributed (default
        for A, IMG and BlockQuote).
        The key is the tag; the value is a list of allowed attributes.
Overrides: object.__init__

### xml(self) | source code
Overrides: XmlComponent.xml

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### __hash__(self) (Hashing function) | source code
hash(x) Overrides: object.__hash__ (inherited documentation)