Docs for globals()

[ Python Tutorial ] [ Python Libraries ] [ web2py epydoc ]

Description





1.
Global variables


Attributes


A <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

B <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

BEAUTIFY <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>
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><b><div>hello</div></b></td><td align="top">:</td><td><div>world</div></td></tr></table></div></td></tr></table></div>' turns any list, dictionarie, etc into decent looking html.

BODY <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

BR <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

CENTER <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

CLEANUP <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=CLEANUP()) removes special characters on validation

CODE <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>
displays code in HTML with syntax highlighting. Exmaple: {{=CODE("print 'hello world'",language='python',link=None,counter=1,styles={})}} supported languages are "python", "html_plain", "c", "cpp", "web2py", "html". The "html" language interprets {{ and }} tags as "web2py" code, "html_plain" doesn't. if a link='/exmaples/global/vars/' is provided web2py keywords are linked to the online docs. the counter is used for line numbering, counter can be None or a prompt string.

CRYPT <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=CRYPT()) encodes the value on validation with md5 checkshum

DIV <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
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

EM <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

EMBED <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

FIELDSET <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

FORM <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>
example: >>> form=FORM(INPUT(_name="test",requires=IS_NOT_EMPTY())) >>> form.xml() '<form action="" enctype="multipart/form-data" method="post"><input name="test" /></form>' a FORM is container for INPUT, TEXTAREA, SELECT and other helpers form has one important method: form.accepts(request.vars, session) if form is accepted (and all validators pass) form.vars containes the accepted vars, otherwise form.errors contains the errors. in case of errors the form is modified to present the errors to the user.

H1 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

H2 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

H3 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

H4 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

H5 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

H6 <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

HEAD <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

HR <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

HTML <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

HTTP <type 'type'> extends (<type 'exceptions.BaseException'>,) belongs to class <type 'type'>

IFRAME <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

IMG <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

INPUT <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>
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" />' >>> 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=. value is used to pass the initial value for the input field. value differs from _value because it works for checkboxes, radio, textarea and select/option too. for a checkbox value should be '' or 'on'. for a radio or select/option value should be the _value of the checked/selected item. requres should be None, or a validator or a list of validators for the value of the field.

IS_ALPHANUMERIC <type 'type'> extends (<class 'gluon.validators.IS_MATCH'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_ALPHANUMERIC())

IS_DATE <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_DATE()) date has to be in the ISO8960 format YYYY-MM-DD

IS_DATETIME <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_DATETIME()) datetime has to be in the ISO8960 format YYYY-MM-DD hh:mm:ss

IS_EMAIL <type 'type'> extends (<class 'gluon.validators.IS_MATCH'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_EMAIL())

IS_EXPR <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_EXPR('5<int(value)<10')) the argument of IS_EXPR must be python condition IS_EXPR('int(value)<2')('1') returns (1,None) IS_EXPR('int(value)<2')('2') returns ('2','invalid expression!')

IS_FLOAT_IN_RANGE <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_FLOAT_IN_RANGE(0,10))

IS_INT_IN_RANGE <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_INT_IN_RANGE(0,10))

IS_IN_DB <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_IN_DB(db,db.table)) used for reference fields, rendered as a dropbox

IS_IN_SET <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_IN_SET(['max','john'])) the argument of IS_IN_SET must be a list or set

IS_LENGTH <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_LENGTH(32)) the argument of IS_LENGTH is the man number of characters

IS_LIST_OF <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>

IS_LOWER <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>

IS_MATCH <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_MATCH('.+')) the argument of IS_MATCH is a regular expression. IS_MATCH('.+')('hello') returns ('hello',None) IS_MATCH('.+')('') returns ('','invalid!')

IS_NOT_EMPTY <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_NOT_EMPTY())

IS_NOT_IN_DB <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_NOT_IN_DB(db,db.table)) makes the field unique

IS_NULL_OR <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>

IS_TIME <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_TIME()) understands the follwing formats hh:mm:ss [am/pm] hh:mm [am/pm] hh [am/pm] [am/pm] is options, ':' can be replaced by any other non-digit

IS_UPPER <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>

IS_URL <type 'type'> extends (<class 'gluon.validators.IS_MATCH'>,) belongs to class <type 'type'>
example: INPUT(_type='text',_name='name',requires=IS_URL())

LABEL <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

LI <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

LINK <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

META <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

OBJECT <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

OL <type 'type'> extends (<class 'gluon.html.UL'>,) belongs to class <type 'type'>

ON <type 'bool'> belongs to class <type 'bool'>
bool(x) -> bool Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

OPTION <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

P <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

PRE <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

SCRIPT <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

SELECT <type 'type'> extends (<class 'gluon.html.INPUT'>,) belongs to class <type 'type'>
example: >>> SELECT('yes','no',_name='selector',value='yes',requires=IS_IN_SET(['yes','no'])).xml() '<select name="selector"><option selected="selected" value="yes">yes</option><option value="no">no</option></select>'

SPAN <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

SQLDB <type 'type'> extends (<class 'gluon.sql.SQLStorage'>,) belongs to class <type 'type'>
an instance of this class represents a database connection Example: db=SQLDB('sqlite://test.db') db.define_table('tablename',SQLField('fieldname1'), SQLField('fieldname2'))

SQLFORM <type 'type'> extends (<class 'gluon.html.FORM'>,) belongs to class <type 'type'>
SQLFORM is used to map a table (and a current record) into an HTML form given a SQLTable stored in db.table SQLFORM(db.table) generates an insert form record=db(db.table.id==some_id).select()[0] SQLFORM(db.table,record) generates an update form SQLFORM(db.table,record,deletable=True) generates an update with a delete button optional arguments: fields: a list of fields that should be placed in the form, default is all. labels: a dictionary with labels for each field. keys are field names. col3 : a dictionary with content for an optional third column (right of each field). keys are field names. linkto: the URL of a controller/function to access referencedby records see controller appadmin.py for examples upload: the URL of a controller/function to download an uploaded file see controller appadmin.py for examples any named optional attribute is passed to the <form> tag for example _class, _id, _style, _action,_method, etc.

SQLField <type 'type'> extends (<class 'gluon.sql.SQLXorable'>,) belongs to class <type 'type'>
an instance of this class represents a database field example: a=SQLField(name,'string',length=32,required=False,default=None,requires=IS_NOT_EMPTY(),notnull=False,unique=False,uploadfield=None,widget=None,label=None) to be used as argument of SQLDB.define_table allowed field types: string, boolean, integer, double, text, blob, date, time, datetime, upload, password strings must have a length or 32 by default. fields should have a default or they will be required in SQLFORMs the requires argument are used to validate the field input in SQLFORMs

SQLTABLE <type 'type'> extends (<class 'gluon.html.TABLE'>,) belongs to class <type 'type'>
given a SQLRows object, as returned by a db().select(), generates and html table with the rows. optional arguments: linkto: URL to edit individual records uplaod: URL to download uploaded files orderby: Add an orderby link to column headers. headers: dictionary of headers to headers redefinions truncate: length at which to truncate text in table cells. Defaults to 16 characters. optional names attributes for passed to the <table> tag

STYLE <type 'type'> extends (<class 'gluon.html.SCRIPT'>,) belongs to class <type 'type'>

T <class 'gluon.languages.translator'> belongs to class <class 'gluon.languages.translator'>
this class is intantiated once in gluon/main.py as the T object T.force(None) # turns off translation T.force('fr, it') # forces web2py to translate using fr.py or it.py T("Hello World") # translates "Hello World" using the selected file notice 1: there is no need to force since, by default, T uses accept_langauge to determine a translation file. notice 2: en and en-en are considered different languages!

TABLE <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TAG <class 'gluon.html.__TAG__'> extends <function <lambda> at 0x55664b816908> belongs to class <class 'gluon.html.__TAG__'>
TAG factory example: >>> print TAG.first(TAG.second('test'),_key=3) <first key="3"><second>test</second></first>

TBODY <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TD <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TEXTAREA <type 'type'> extends (<class 'gluon.html.INPUT'>,) belongs to class <type 'type'>
TEXTAREA(_name='sometext',value='bla '*100,requires=IS_NOT_EMPTY()) 'bla bla bla ...' will be the content of the textarea field.

TFOOT <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TH <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

THEAD <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TITLE <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TR <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

TT <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

UL <type 'type'> extends (<class 'gluon.html.DIV'>,) belongs to class <type 'type'>

URL <type 'function'> belongs to class <type 'function'>
example: >>> URL(a='a',c='c',f='f',args=['x','y','z'],vars={'p':1, 'q':2}) '/a/c/f/x/y/z?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.applicaiton, 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.

XML <type 'type'> extends (<type 'object'>,) belongs to class <type 'type'>
example: >>> XML('<h1>Hello</h1>').xml() '<h1>Hello</h1>' use it to wrap a string that contains XML/HTML so that it will not be escaped by the template

__builtins__ <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary. dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs. dict(seq) -> new dictionary initialized as if via: d = {} for k, v in seq: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

cache <class 'gluon.cache.Cache'> belongs to class <class 'gluon.cache.Cache'>

embed64 <type 'function'> belongs to class <type 'function'>

purchased <class 'gluon.sql.SQLQuery'> belongs to class <class 'gluon.sql.SQLQuery'>
a query object necessary to define a set. t can be stored or can be passed to SQLDB.__call__() to obtain a SQLSet Example: query=db.users.name=='Max' set=db(query) records=set.select()

redirect <type 'function'> belongs to class <type 'function'>

request <class 'gluon.globals.Request'> belongs to class <class 'gluon.globals.Request'>
defines the request object and the default values of its members

response <class 'gluon.globals.Response'> belongs to class <class 'gluon.globals.Response'>
defines the response object and the default values of its members response.write( ) can be used to write in the output html

session <class 'gluon.globals.Session'> belongs to class <class 'gluon.globals.Session'>
defines the session object and the default values of its members (None)

xmlescape <type 'function'> belongs to class <type 'function'>