| Home | Trees | Indices | Help |
|
|---|
|
|
|
|||
|
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 examples:: >>> INPUT(_type='text', _name='name', value='Max').xml() '<input name="name" type="text" value="Max" />' >>> INPUT(_type='checkbox', _name='checkbox', value='on').xml() '<input checked="checked" name="checkbox" type="checkbox" value="on" />' >>> INPUT(_type='radio', _name='radio', _value='yes', value='yes').xml() '<input checked="checked" name="radio" type="radio" value="yes" />' >>> INPUT(_type='radio', _name='radio', _value='no', value='yes').xml() '<input name="radio" type="radio" value="no" />' the input helper takes two special attributes value= and requires=. |
|||
|
TEXTAREA example: |
|||
| OPTION | |||
| OBJECT | |||
| OPTGROUP | |||
|
SELECT example: |
|||
| FIELDSET | |||
| LEGEND | |||
|
FORM example: |
|||
|
BEAUTIFY example:: >>> BEAUTIFY(['a', 'b', {'hello': 'world'}]).xml() '<div><table><tr><td><div>a</div></td></tr><tr><td><div>b</div></td></tr><tr><td><div><table><tr><td style="font-weight:bold;">hello</td><td valign="top">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>' turns any list, dictionary, etc into decent looking html. |
|||
|
MENU Used to build menus... |
|||
|
web2pyHTMLParser obj = web2pyHTMLParser(text) parses and html/xml text into web2py helpers. |
|||
|
MARKMIN For documentation: http://web2py.com/examples/static/markmin.html |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
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 URL
example::
>>> str(URL(a='a', c='c', f='f', args=['x', 'y', 'z'],
... vars={'p':1, 'q':2}, anchor='1'))
'/a/c/f/x/y/z?p=1&q=2#1'
>>> str(URL(a='a', c='c', f='f', args=['x', 'y', 'z'],
... vars={'p':(1,3), 'q':2}, anchor='1'))
'/a/c/f/x/y/z?p=1&p=3&q=2#1'
>>> str(URL(a='a', c='c', f='f', args=['x', 'y', 'z'],
... vars={'p':(3,1), 'q':2}, anchor='1'))
'/a/c/f/x/y/z?p=3&p=1&q=2#1'
>>> str(URL(a='a', c='c', f='f', anchor='1+2'))
'/a/c/f#1%2B2'
>>> str(URL(a='a', c='c', f='f', args=['x', 'y', 'z'],
... vars={'p':(1,3), 'q':2}, anchor='1', hmac_key='key'))
'/a/c/f/x/y/z?p=1&p=3&q=2&_signature=5d06bb8a4a6093dd325da2ee591c35c61afbd3c6#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)
:param hmac_key: key to use when generating hmac signature (optional)
:param hash_vars: which of the vars to include in our hmac signature
True (default) - hash all vars, False - hash none of the vars,
iterable - hash only the included vars ['key1','key2']
:param _request: used internally for URL rewrite
:param scheme: URI scheme (True, 'http' or 'https', etc); forces absolute URL (optional)
:param host: string to force absolute URL with host (True means http_host)
:param port: optional port number (forces absolute URL)
:raises SyntaxError: when no application, controller or function is
available
:raises SyntaxError: when a CRLF is found in the generated url
|
Verifies that a request's args & vars have not been tampered with by the user
:param request: web2py's request object
:param hmac_key: the key to authenticate with, must be the same one previously
used when calling URL()
:param hash_vars: which vars to include in our hashing. (Optional)
Only uses the 1st value currently (it's really a hack for the _gURL.verify lambda)
True (or undefined) means all, False none, an iterable just the specified keys
do not call directly. Use instead:
URL.verify(hmac_key='...')
the key has to match the one used to generate the URL.
>>> r = Storage()
>>> gv = Storage(p=(1,3),q=2,_signature='5d06bb8a4a6093dd325da2ee591c35c61afbd3c6')
>>> r.update(dict(application='a', controller='c', function='f'))
>>> r['args'] = ['x', 'y', 'z']
>>> r['get_vars'] = gv
>>> verifyURL(r, 'key')
True
>>> verifyURL(r, 'kay')
False
>>> r.get_vars.p = (3, 1)
>>> verifyURL(r, 'key')
True
>>> r.get_vars.p = (3, 2)
>>> verifyURL(r, 'key')
False
|
A proxy function for URL which contains knowledge of a given request object. Usage is exactly like URL except you do not have to specify r=request! |
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 |
>>> 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.0beta1 on Mon Apr 25 15:04:05 2011 | http://epydoc.sourceforge.net |