API

Models, controllers, and views are executed in an environment where the following objects are already imported for us:

Global Objects:

  1. request, response, session, cache

Internationalization:

  1. T

Navigation:

  1. redirect, HTTP

Helpers:

  1. XML, URL, BEAUTIFY
  2. A, ASSIGNJS, B, BODY, BR, BUTTON, CENTER, CODE, COL, COLGROUP,
  3. DIV, EM, EMBED, FIELDSET, FORM, H1, H2, H3, H4, H5, H6,
  4. HEAD, HR, HTML, I, IFRAME, IMG, INPUT, LABEL, LEGEND,
  5. LI, LINK, OL, UL, META, OBJECT, OPTION, P, PRE,
  6. SCRIPT, OPTGROUP, SELECT, SPAN, STRONG, STYLE,
  7. TABLE, TAG, TD, TEXTAREA, TH, THEAD, TBODY, TFOOT,
  8. TITLE, TR, TT, XHTML, xmlescape, embed64
  9. CAT, MARKMIN, MENU, ON

Forms and tables

  1. SQLFORM (SQLFORM.factory, SQLFORM.grid, SQLFORM.smartgrid)

Validators:

  1. CLEANUP, CRYPT, IS_ALPHANUMERIC, IS_DATE_IN_RANGE, IS_DATE,
  2. IS_DATETIME_IN_RANGE, IS_DATETIME, IS_DECIMAL_IN_RANGE,
  3. IS_EMAIL, IS_EMPTY_OR, IS_EXPR, IS_FLOAT_IN_RANGE, IS_IMAGE,
  4. IS_IN_DB, IS_IN_SET, IS_INT_IN_RANGE, IS_IPV4, IS_LENGTH,
  5. IS_LIST_OF, IS_LOWER, IS_MATCH, IS_EQUAL_TO, IS_NOT_EMPTY,
  6. IS_NOT_IN_DB, IS_NULL_OR, IS_SLUG, IS_STRONG, IS_TIME,
  7. IS_UPLOAD_FILENAME, IS_UPPER, IS_URL

Database:

  1. 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:

  1. from gluon.tools import Auth, Crud, Service

They are imported in db.py in the scaffolding application.