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

Class DIV

source code

  object --+    
           |    
XmlComponent --+
               |
              DIV
Known Subclasses:

HTML helper, for easy generating and manipulating a DOM structure. Little or no validation is done.

Behaves like a dictionary regarding updating of attributes. Behaves like a list regarding inserting/appending components.

example:

   >>> DIV('hello', 'world', _style='color:red;').xml()
   '<div style="color:red;">helloworld</div>'

all other HTML helpers are derived from DIV.

_something="value" attributes are transparently translated into something="value" HTML attributes

Instance Methods [hide private]
 
__delitem__(self, i)
deletes attribute with name 'i' or component #i.
source code
 
__getitem__(self, i)
gets attribute with name 'i' or component #i.
source code
 
__init__(self, *components, **attributes)
:param *components: any components that should be nested in this element :param **attributes: any attributes you want to give to this element
source code
 
__len__(self)
returns the number of included components
source code
 
__nonzero__(self)
always return True
source code
 
__setitem__(self, i, value)
sets attribute with name 'i' or component #i.
source code
 
__str__(self)
str(COMPONENT) returns equals COMPONENT.xml()
source code
 
_fixup(self)
Handling of provided components.
source code
 
_postprocessing(self)
Handling of attributes (normally the ones not prefixed with '_').
source code
 
_traverse(self, status) source code
 
_validate(self)
nothing to validate yet.
source code
 
_wrap_components(self, allowed_parents, wrap_parent=None, wrap_lambda=None)
helper for _fixup.
source code
 
_xml(self)
helper for xml generation.
source code
 
append(self, value)
list style appending of components
source code
 
element(self, *args, **kargs)
find the first component that matches the supplied attribute dictionary, or None if nothing could be found
source code
 
elements(self, *args, **kargs)
find all component that match the supplied attribute dictionary, or None if nothing could be found
source code
 
insert(self, i, value)
list style inserting of components
source code
 
update(self, **kargs)
dictionary like updating of the tag attributes
source code
 
xml(self)
generates the xml for this component.
source code

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

Class Variables [hide private]
  tag = 'div'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__delitem__(self, i)
(Index deletion operator)

source code 

deletes attribute with name 'i' or component #i.

:param i: index
   if i is a string: the name of the attribute
   otherwise references to number of the component

__getitem__(self, i)
(Indexing operator)

source code 

gets attribute with name 'i' or component #i.
If attribute 'i' is not found returns None

:param i: index
   if i is a string: the name of the attribute
   otherwise references to number of the component

__init__(self, *components, **attributes)
(Constructor)

source code 

:param *components: any components that should be nested in this element :param **attributes: any attributes you want to give to this element

:raises SyntaxError: when a stand alone tag receives components

Overrides: object.__init__

__setitem__(self, i, value)
(Index assignment operator)

source code 

sets attribute with name 'i' or component #i.

:param i: index
   if i is a string: the name of the attribute
   otherwise references to number of the component
:param value: the new value

__str__(self)
(Informal representation operator)

source code 

str(COMPONENT) returns equals COMPONENT.xml()

Overrides: object.__str__

_fixup(self)

source code 

Handling of provided components.

Nothing to fixup yet. May be overridden by subclasses, eg for wrapping some components in another component or blocking them.

_postprocessing(self)

source code 

Handling of attributes (normally the ones not prefixed with '_').

Nothing to postprocess yet. May be overridden by subclasses

_validate(self)

source code 

nothing to validate yet. May be overridden by subclasses

_wrap_components(self, allowed_parents, wrap_parent=None, wrap_lambda=None)

source code 

helper for _fixup. Checks if a component is in allowed_parents,
otherwise wraps it in wrap_parent

:param allowed_parents: (tuple) classes that the component should be an
    instance of
:param wrap_parent: the class to wrap the component in, if needed
:param wrap_lambda: lambda to use for wrapping, if needed

_xml(self)

source code 

helper for xml generation. Returns separately:
- the component attributes
- the generated xml of the inner components

Component attributes start with an underscore ('_') and
do not have a False or None value. The underscore is removed
and the name will be in lower case.
A value of True is replaced with the attribute name.

:returns: tuple: (attributes, components)

element(self, *args, **kargs)

source code 

find the first component that matches the supplied attribute dictionary, or None if nothing could be found

Also the components of the components are searched.

elements(self, *args, **kargs)

source code 

find all component that match the supplied attribute dictionary, or None if nothing could be found

All components of the components are searched.

xml(self)

source code 

generates the xml for this component.

Overrides: XmlComponent.xml