API
Models, controllers, and views are executed in an environment where the following objects are already imported for us:
Global Objects:
request, response, session, cache
Internationalization:
T
Navigation:
redirect, HTTP
Helpers:
XML, URL, BEAUTIFY
A, ASSIGNJS, B, BODY, BR, BUTTON, CENTER, CODE, COL, COLGROUP,
DIV, EM, EMBED, FIELDSET, FORM, H1, H2, H3, H4, H5, H6,
HEAD, HR, HTML, I, IFRAME, IMG, INPUT, LABEL, LEGEND,
LI, LINK, OL, UL, META, OBJECT, OPTION, P, PRE,
SCRIPT, OPTGROUP, SELECT, SPAN, STRONG, STYLE,
TABLE, TAG, TD, TEXTAREA, TH, THEAD, TBODY, TFOOT,
TITLE, TR, TT, XHTML, xmlescape, embed64
CAT, MARKMIN, MENU, ON
Forms and tables
SQLFORM (SQLFORM.factory, SQLFORM.grid, SQLFORM.smartgrid)
Validators:
CLEANUP, CRYPT, IS_ALPHANUMERIC, IS_DATE_IN_RANGE, IS_DATE,
IS_DATETIME_IN_RANGE, IS_DATETIME, IS_DECIMAL_IN_RANGE,
IS_EMAIL, IS_EMPTY_OR, IS_EXPR, IS_FLOAT_IN_RANGE, IS_IMAGE,
IS_IN_DB, IS_IN_SET, IS_INT_IN_RANGE, IS_IPV4, IS_LENGTH,
IS_LIST_OF, IS_LOWER, IS_MATCH, IS_EQUAL_TO, IS_NOT_EMPTY,
IS_NOT_IN_DB, IS_NULL_OR, IS_SLUG, IS_STRONG, IS_TIME,
IS_UPLOAD_FILENAME, IS_UPPER, IS_URL
Database:
DAL, Field
For backward compatibility SQLDB=DAL
and SQLField=Field
. We encourage you to use the new syntax DAL
and Field
, instead of the old syntax.
Other objects and modules are defined in the libraries, but they are not automatically imported since they are not used as often.
The core API entities in the web2py execution environment are request
, response
, session
, cache
, URL
, HTTP
, redirect
and T
and are discussed below.
A few objects and functions, including Auth, Crud and Service, are defined in “gluon/tools.py” and they need to be imported as necessary:
from gluon.tools import Auth, Crud, Service
They are imported in db.py
in the scaffolding application.