Package glue :: Module markup :: Class page
[hide private]
[frames] | no frames]

Class page

source code

Known Subclasses:

This is our main class representing a document. Elements are added as attributes of an instance of this class.

Instance Methods [hide private]
 
__call__(self, escape=False)
Return the document as a string.
source code
 
__getattr__(self, attr) source code
 
__init__(self, mode='strict_html', case='lower', onetags=None, twotags=None, separator='\n', class_=None)
Stuff that effects the whole document.
source code
 
__str__(self) source code
 
add(self, text)
This is an alias to addcontent.
source code
 
addcontent(self, text)
Add some text to the main part of the document
source code
 
addfooter(self, text)
Add some text to the bottom of the document
source code
 
addheader(self, text)
Add some text to the top of the document
source code
 
css(self, filelist)
This convenience function is only useful for html.
source code
 
init(self, lang='en', css=None, metainfo=None, title=None, header=None, footer=None, charset=None, encoding=None, doctype=None, bodyattrs=None, script=None, base=None)
This method is used for complete documents with appropriate doctype, encoding, title, etc information.
source code
 
metainfo(self, mydict)
This convenience function is only useful for html.
source code
 
scripts(self, mydict)
Only useful in html, mydict is dictionary of src:type pairs or a list of script sources [ 'src1', 'src2', ...
source code
Method Details [hide private]

__call__(self, escape=False)
(Call operator)

source code 
Return the document as a string.

escape --   False   print normally
            True    replace < and > by &lt; and &gt;
                    the default escape sequences in most browsers

__init__(self, mode='strict_html', case='lower', onetags=None, twotags=None, separator='\n', class_=None)
(Constructor)

source code 
Stuff that effects the whole document.

mode -- 'strict_html'   for HTML 4.01 (default)
        'html'          alias for 'strict_html'
        'loose_html'    to allow some deprecated elements
        'xml'           to allow arbitrary elements

case -- 'lower'         element names will be printed in lower case (default)
        'upper'         they will be printed in upper case
        'given'         element names will be printed as they are given

onetags --              list or tuple of valid elements with opening tags only
twotags --              list or tuple of valid elements with both opening and closing tags
                        these two keyword arguments may be used to select
                        the set of valid elements in 'xml' mode
                        invalid elements will raise appropriate exceptions

separator --            string to place between added elements, defaults to newline

class_ --               a class that will be added to every element if defined

css(self, filelist)

source code 

This convenience function is only useful for html. It adds css stylesheet(s) to the document via the <link> element.

init(self, lang='en', css=None, metainfo=None, title=None, header=None, footer=None, charset=None, encoding=None, doctype=None, bodyattrs=None, script=None, base=None)

source code 
This method is used for complete documents with appropriate
doctype, encoding, title, etc information. For an HTML/XML snippet
omit this method.

lang --     language, usually a two character string, will appear
            as <html lang='en'> in html mode (ignored in xml mode)

css --      Cascading Style Sheet filename as a string or a list of
            strings for multiple css files (ignored in xml mode)

metainfo -- a dictionary in the form { 'name':'content' } to be inserted
            into meta element(s) as <meta name='name' content='content'>
            (ignored in xml mode)

base     -- set the <base href="..."> tag in <head>

bodyattrs --a dictionary in the form { 'key':'value', ... } which will be added
            as attributes of the <body> element as <body key='value' ... >
            (ignored in xml mode)

script --   dictionary containing src:type pairs, <script type='text/type' src=src></script>
            or a list of [ 'src1', 'src2', ... ] in which case 'javascript' is assumed for all

title --    the title of the document as a string to be inserted into
            a title element as <title>my title</title> (ignored in xml mode)

header --   some text to be inserted right after the <body> element
            (ignored in xml mode)

footer --   some text to be inserted right before the </body> element
            (ignored in xml mode)

charset --  a string defining the character set, will be inserted into a
            <meta http-equiv='Content-Type' content='text/html; charset=myset'>
            element (ignored in xml mode)

encoding -- a string defining the encoding, will be put into to first line of
            the document as <?xml version='1.0' encoding='myencoding' ?> in
            xml mode (ignored in html mode)

doctype --  the document type string, defaults to
            <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
            in html mode (ignored in xml mode)

metainfo(self, mydict)

source code 

This convenience function is only useful for html. It adds meta information via the <meta> element, the argument is a dictionary of the form { 'name':'content' }.

scripts(self, mydict)

source code 

Only useful in html, mydict is dictionary of src:type pairs or a list of script sources [ 'src1', 'src2', ... ] in which case 'javascript' is assumed for type. Will be rendered as <script type='text/type' src=src></script>