| Home | Trees | Indices | Help |
|
|---|
|
|
This file is part of web2py Web Framework (Copyrighted, 2007-2010). Developed by Massimo Di Pierro <mdipierro@cs.depaul.edu>. License: GPL v2
|
|||
|
XmlComponent Abstract root for all Html components |
|||
|
XML use it to wrap a string that contains XML/HTML so that it will not be escaped by the template |
|||
|
DIV HTML helper, for easy generating and manipulating a DOM structure. |
|||
|
__TAG__ TAG factory example: |
|||
|
HTML There are four predefined document type definitions. |
|||
|
XHTML This is XHTML version of the HTML helper. |
|||
| HEAD | |||
| TITLE | |||
| META | |||
| LINK | |||
| SCRIPT | |||
| STYLE | |||
| IMG | |||
| SPAN | |||
| BODY | |||
| H1 | |||
| H2 | |||
| H3 | |||
| H4 | |||
| H5 | |||
| H6 | |||
|
P Will replace ``\n`` by ``<br />`` if the `cr2br` attribute is provided. |
|||
| B | |||
| BR | |||
| HR | |||
| A | |||
| EM | |||
| EMBED | |||
| TT | |||
| PRE | |||
| CENTER | |||
|
CODE displays code in HTML with syntax highlighting. |
|||
| LABEL | |||
| LI | |||
|
UL UL Component. |
|||
| OL | |||
| TD | |||
| TH | |||
|
TR TR Component. |
|||
| THEAD | |||
| TBODY | |||
| TFOOT | |||
|
TABLE TABLE Component. |
|||
| I | |||
| IFRAME | |||
|
INPUT INPUT Component |
|||
|
TEXTAREA example: |
|||
| OPTION | |||
| OBJECT | |||
|
SELECT example: |
|||
| FIELDSET | |||
| LEGEND | |||
|
FORM example: |
|||
|
BEAUTIFY example: |
|||
|
MENU Used to build menus |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
regex_crlf = re.compile(r'
|
|||
ON = True
|
|||
TAG = __TAG__()
|
|||
|
|||
returns an escaped string of the provided data :param data: the data to be escaped :param quote: optional (default False) |
generate a relative URL
example::
>>> URL(a='a', c='c', f='f', args=['x', 'y', 'z'],
... vars={'p':1, 'q':2}, anchor='1')
'/a/c/f/x/y/z#1?q=2&p=1'
generates a url "/a/c/f" corresponding to application a, controller c
and function f. If r=request is passed, a, c, f are set, respectively,
to r.application, r.controller, r.function.
The more typical usage is:
URL(r=request, f='index') that generates a url for the index function
within the present application and controller.
:param a: application (default to current if r is given)
:param c: controller (default to current if r is given)
:param f: function (default to current if r is given)
:param r: request (optional)
:param args: any arguments (optional)
:param vars: any variables (optional)
:param anchor: anchorname, without # (optional)
:raises SyntaxError: when no application, controller or function is
available
:raises SyntaxError: when a CRLF is found in the generated url
|
helper to encode the provided (binary) data into base64. :param filename: if provided, opens and reads this file in 'rb' mode :param file: if provided, reads this file :param data: if provided, uses the provided data |
Example: >>> from validators import * >>> print DIV(A('click me', _href=URL(a='a', c='b', f='c')), BR(), HR(), DIV(SPAN("World"), _class='unknown')).xml() <div><a href="/a/b/c">click me</a><br /><hr /><div class="unknown"><span>World</span></div></div> >>> print DIV(UL("doc","cat","mouse")).xml() <div><ul><li>doc</li><li>cat</li><li>mouse</li></ul></div> >>> print DIV(UL("doc", LI("cat", _class='feline'), 18)).xml() <div><ul><li>doc</li><li class="feline">cat</li><li>18</li></ul></div> >>> print TABLE(['a', 'b', 'c'], TR('d', 'e', 'f'), TR(TD(1), TD(2), TD(3))).xml() <table><tr><td>a</td><td>b</td><td>c</td></tr><tr><td>d</td><td>e</td><td>f</td></tr><tr><td>1</td><td>2</td><td>3</td></tr></table> >>> form=FORM(INPUT(_type='text', _name='myvar', requires=IS_EXPR('int(value)<10'))) >>> print form.xml() <form action="" enctype="multipart/form-data" method="post"><input name="myvar" type="text" /></form> >>> print form.accepts({'myvar':'34'}, formname=None) False >>> print form.xml() <form action="" enctype="multipart/form-data" method="post"><input name="myvar" type="text" value="34" /><div class="error" id="myvar__error">invalid expression</div></form> >>> print form.accepts({'myvar':'4'}, formname=None, keepvalues=True) True >>> print form.xml() <form action="" enctype="multipart/form-data" method="post"><input name="myvar" type="text" value="4" /></form> >>> form=FORM(SELECT('cat', 'dog', _name='myvar')) >>> print form.accepts({'myvar':'dog'}, formname=None, keepvalues=True) True >>> print form.xml() <form action="" enctype="multipart/form-data" method="post"><select name="myvar"><option value="cat">cat</option><option selected="selected" value="dog">dog</option></select></form> >>> form=FORM(INPUT(_type='text', _name='myvar', requires=IS_MATCH('^\w+$', 'only alphanumeric!'))) >>> print form.accepts({'myvar':'as df'}, formname=None) False >>> print form.xml() <form action="" enctype="multipart/form-data" method="post"><input name="myvar" type="text" value="as df" /><div class="error" id="myvar__error">only alphanumeric!</div></form> >>> session={} >>> form=FORM(INPUT(value="Hello World", _name="var", requires=IS_MATCH('^\w+$'))) >>> if form.accepts({}, session,formname=None): print 'passed' >>> if form.accepts({'var':'test ', '_formkey': session['_formkey[None]']}, session, formname=None): print 'passed' |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Feb 3 10:53:17 2010 | http://epydoc.sourceforge.net |