If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

People are always asking about the web2py environment objects, so I use the excellent online debugger and created a breakpoint on my very first line of the first model. It generated a list of LOCAL and GLOBAL objects.

My plan is to comment each one of those objects here in the future, want to help? ask me admin access to this post.

 

When you load your new web2py applications, "welcome" in example, without any object defined, clean models, no tables, no auth, no plugins. You should have the following elements inserted automatically in web2py environment. Note that we have a "local" which means the scope of each single request running on web2py controlled environment. and also we have globals.

 

Locals

Object Arguments Docs Definition
A

_href: href in html tag

_target: target html tag

HTML standard link/anchor

On the controller: 
A("Google", _href="http://www.google.com")

On the View: 
{{=A("index", _href=URL('index'))}}
<class 'gluon.html.A'>
<type 'type'>
B :

HTML standard bold

On the controller: 
B('Hello World')

On the View: 
{{=B('Hello World')}}

Result: 
<b>Hello World</b>
<class 'gluon.html.B'>
<type 'type'>
BEAUTIFY :

Turns any list, dictionary, etc into html

On the controller: 
BEAUTIFY({"a": ["hello", XML("world")], "b": (1, 2)})

On the View: 
{{=BEAUTIFY({"a": ["hello", XML("world")], "b": (1, 2)})}}

Result:
<table>
<tr><td>a</td><td>:</td><td>hello<br />world</td></tr>
<tr><td>b</td><td>:</td><td>1<br />2</td></tr>
</table>
<class 'gluon.html.BEAUTIFY'>
<type 'type'>
BODY :

HTML standard body

On the controller: 
BODY('<hello>', XML('<b>world</b>'), _bgcolor='red')

On the View: 
{{=BODY('<hello>', XML('<b>world</b>'), _bgcolor='red')}}

Result:
<body bgcolor="red">&lt;hello&gt;<b>world</b></body>
<class 'gluon.html.BODY'>
<type 'type'>
BR  

HTML Line break
 

BR() => <br />

B0R() * 2 <br /><br />
<class 'gluon.html.BR'>
<type 'type'>
BUTTON :

HTML standard button

On the controller:
BUTTON('hello', _class='btn btn-success', _onclick='alert("hello");')

On the view:
{{=BUTTON('hello', _class='btn btn-success', _onclick='alert("hello");')}}

Result:
<button onclick="alert(&quot;hello&quot;);" class="btn btn-success">hello</button>
<class 'gluon.html.BUTTON'>
<type 'type'>
CAT : ConCATenate multiple objects

CAT(A('test'), BR(), DIV(_class="foo")) => "<a>test</a><br /><div class="foo"></div>"
<class 'gluon.html.CAT'>
<type 'type'>
CENTER :

HTML standard center

On the controller:
CENTER('hello', _class='test', _id=0)

On the view:
{{=CENTER('hello', _class='test', _id=0)}}

Result:
<center id="0" class="test">hello</center>
<class 'gluon.html.CENTER'>
<type 'type'>
CLEANUP :  
<class 'gluon.validators.CLEANUP'>
<type 'type'>
CODE :  
<class 'gluon.html.CODE'>
<type 'type'>
COL :  
<class 'gluon.html.COL'>
<type 'type'>
COLGROUP :  
<class 'gluon.html.COLGROUP'>
<type 'type'>
CRYPT :  
<class 'gluon.validators.CRYPT'>
<type 'type'>
DAL :  
<class 'gluon.dal.DAL'>
<type 'type'>
DIV :  
<class 'gluon.html.DIV'>
<type 'type'>
EM :  
<class 'gluon.html.EM'>
<type 'type'>
EMBED :  
<class 'gluon.html.EMBED'>
<type 'type'>
FIELDSET :  
<class 'gluon.html.FIELDSET'>
<type 'type'>
FORM :  
<class 'gluon.html.FORM'>
<type 'type'>
Field :  
<class 'gluon.dal.Field'>
<type 'type'>
H1 :  
<class 'gluon.html.H1'>
<type 'type'>
H2 :  
<class 'gluon.html.H2'>
<type 'type'>
H3 :  
<class 'gluon.html.H3'>
<type 'type'>
H4 :  
<class 'gluon.html.H4'>
<type 'type'>
H5 :  
<class 'gluon.html.H5'>
<type 'type'>
H6 :  
<class 'gluon.html.H6'>
<type 'type'>
HEAD :  
<class 'gluon.html.HEAD'>
<type 'type'>
HR :  
<class 'gluon.html.HR'>
<type 'type'>
HTML :  
<class 'gluon.html.HTML'>
<type 'type'>
HTTP :  
<class 'gluon.http.HTTP'>
<type 'type'>
I :  
<class 'gluon.html.I'>
<type 'type'>
IFRAME :  
<class 'gluon.html.IFRAME'>
<type 'type'>
IMG :  
<class 'gluon.html.IMG'>
<type 'type'>
INPUT :  
<class 'gluon.html.INPUT'>
<type 'type'>
IS_ALPHANUMERIC :  
<class 'gluon.validators.IS_ALPHANUMERIC'>
<type 'type'>
IS_DATE :  
<class 'gluon.validators.IS_DATE'>
<type 'type'>
IS_DATETIME :  
<class 'gluon.validators.IS_DATETIME'>
<type 'type'>
IS_DATETIME_IN_RANGE :  
<class 'gluon.validators.IS_DATETIME_IN_RANGE'>
<type 'type'>
IS_DATE_IN_RANGE :  
<class 'gluon.validators.IS_DATE_IN_RANGE'>
<type 'type'>
IS_DECIMAL_IN_RANGE :  
<class 'gluon.validators.IS_DECIMAL_IN_RANGE'>
<type 'type'>
IS_EMAIL :  
<class 'gluon.validators.IS_EMAIL'>
<type 'type'>
IS_EMPTY_OR :  
<class 'gluon.validators.IS_EMPTY_OR'>
<type 'type'>
IS_EQUAL_TO :  
<class 'gluon.validators.IS_EQUAL_TO'>
<type 'type'>
IS_EXPR :  
<class 'gluon.validators.IS_EXPR'>
<type 'type'>
IS_FLOAT_IN_RANGE :  
<class 'gluon.validators.IS_FLOAT_IN_RANGE'>
<type 'type'>
IS_IMAGE :  
<class 'gluon.validators.IS_IMAGE'>
<type 'type'>
IS_INT_IN_RANGE :  
<class 'gluon.validators.IS_INT_IN_RANGE'>
<type 'type'>
IS_IN_DB :  
<class 'gluon.validators.IS_IN_DB'>
<type 'type'>
IS_IN_SET :  
<class 'gluon.validators.IS_IN_SET'>
<type 'type'>
IS_IPV4 :  
<class 'gluon.validators.IS_IPV4'>
<type 'type'>
IS_JSON :  
<class 'gluon.validators.IS_JSON'>
<type 'type'>
IS_LENGTH :  
<class 'gluon.validators.IS_LENGTH'>
<type 'type'>
IS_LIST_OF :  
<class 'gluon.validators.IS_LIST_OF'>
<type 'type'>
IS_LOWER :  
<class 'gluon.validators.IS_LOWER'>
<type 'type'>
IS_MATCH :  
<class 'gluon.validators.IS_MATCH'>
<type 'type'>
IS_NOT_EMPTY :  
<class 'gluon.validators.IS_NOT_EMPTY'>
<type 'type'>
IS_NOT_IN_DB :  
<class 'gluon.validators.IS_NOT_IN_DB'>
<type 'type'>
IS_NULL_OR :  
<class 'gluon.validators.IS_EMPTY_OR'>
<type 'type'>
IS_SLUG :  
<class 'gluon.validators.IS_SLUG'>
<type 'type'>
IS_STRONG :  
<class 'gluon.validators.IS_STRONG'>
<type 'type'>
IS_TIME :  
<class 'gluon.validators.IS_TIME'>
<type 'type'>
IS_UPLOAD_FILENAME :  
<class 'gluon.validators.IS_UPLOAD_FILENAME'>
<type 'type'>
IS_UPPER :  
<class 'gluon.validators.IS_UPPER'>
<type 'type'>
IS_URL :  
<class 'gluon.validators.IS_URL'>
<type 'type'>
LABEL :  
<class 'gluon.html.LABEL'>
<type 'type'>
LEGEND :  
<class 'gluon.html.LEGEND'>
<type 'type'>
LI :  
<class 'gluon.html.LI'>
<type 'type'>
LINK :  
<class 'gluon.html.LINK'>
<type 'type'>
LOAD :  
<function LOAD at 0x24bcd70>
<type 'function'>
MARKMIN :  
<class 'gluon.html.MARKMIN'>
<type 'type'>
MENU :  
<class 'gluon.html.MENU'>
<type 'type'>
META :  
<class 'gluon.html.META'>
<type 'type'>
OBJECT :  
<class 'gluon.html.OBJECT'>
<type 'type'>
OL :  
<class 'gluon.html.OL'>
<type 'type'>
ON :  
True
<type 'bool'>
OPTGROUP :  
<class 'gluon.html.OPTGROUP'>
<type 'type'>
OPTION :  
<class 'gluon.html.OPTION'>
<type 'type'>
P :  
<class 'gluon.html.P'>
<type 'type'>
PRE :  
<class 'gluon.html.PRE'>
<type 'type'>
SCRIPT :  
<class 'gluon.html.SCRIPT'>
<type 'type'>
SELECT :  
<class 'gluon.html.SELECT'>
<type 'type'>
SPAN :  
<class 'gluon.html.SPAN'>
<type 'type'>
SQLDB :  
<class 'gluon.dal.DAL'>
<type 'type'>
SQLFORM :  
<class 'gluon.sqlhtml.SQLFORM'>
<type 'type'>
SQLField :  
<class 'gluon.dal.Field'>
<type 'type'>
SQLTABLE :  
<class 'gluon.sqlhtml.SQLTABLE'>
<type 'type'>
STRONG :  
<class 'gluon.html.STRONG'>
<type 'type'>
STYLE :  
<class 'gluon.html.STYLE'>
<type 'type'>
T :  
<gluon.languages.translator object at 0x2e56310>
<class 'gluon.languages.translator'>
TABLE :  
<class 'gluon.html.TABLE'>
<type 'type'>
TAG :  
<gluon.html.__TAG__ object at 0x1650b50>
<class 'gluon.html.__TAG__'>
TBODY :  
<class 'gluon.html.TBODY'>
<type 'type'>
TD :  
<class 'gluon.html.TD'>
<type 'type'>
TEXTAREA :  
<class 'gluon.html.TEXTAREA'>
<type 'type'>
TFOOT :  
<class 'gluon.html.TFOOT'>
<type 'type'>
TH :  
<class 'gluon.html.TH'>
<type 'type'>
THEAD :  
<class 'gluon.html.THEAD'>
<type 'type'>
TITLE :  
<class 'gluon.html.TITLE'>
<type 'type'>
TR :  
<class 'gluon.html.TR'>
<type 'type'>
TT :  
<class 'gluon.html.TT'>
<type 'type'>
UL :  
<class 'gluon.html.UL'>
<type 'type'>
URL :  
<function URL at 0x165dc08>
<type 'function'>
XHTML :  
<class 'gluon.html.XHTML'>
<type 'type'>
XML :  
<class 'gluon.html.XML'>
<type 'type'>
cache :  
<gluon.cache.Cache object at 0x2e56790>
<class 'gluon.cache.Cache'>
embed64 :  
<function embed64 at 0x1675398>
<type 'function'>
local_import :  
<function <lambda> at 0x2e52230>
<type 'function'>
redirect :  
<function redirect at 0x13229b0>
<type 'function'>
request :  
<Storage {'function': 'index', 'body': <cStringIO.StringO object at 0x2d40068>, 'wsgi': <Storage {'start_response': <function ...rs': <Storage {}>, 'folder': '/home/rochacbruno/Dropbox/stoodos/w2p/web2py/applications/welcome/', 'post_vars': <Storage {}>}>
<class 'gluon.globals.Request'>
response :  
<Storage {'body': <cStringIO.StringO object at 0x2221ed8>, 'cookies': <SimpleCookie: session_id_welcome='127.0.0.1-c9f951b6-06...629-49c7-8e3e-d2b74805c470', 'postprocessing': [], '_caller': <function <lambda> at 0x2e52500>, 'view': 'default/index.html'}>
<class 'gluon.globals.Response'>
session :  
<Storage {}>
<class 'gluon.globals.Session'>
xmlescape :  
<function xmlescape at 0x165daa0>
<type 'function'>

Globals

HTTP :
("<class '...tp.HTTP'>", "<type 'type'>")
LOAD :
('<functio...x24bcd70>', "<type 'function'>")
SQLDB :
("<class '...dal.DAL'>", "<type 'type'>")
SQLFORM :
("<class '...SQLFORM'>", "<type 'type'>")
SQLField :
("<class '...l.Field'>", "<type 'type'>")
SQLTABLE :
("<class '...QLTABLE'>", "<type 'type'>")
T :
('<gluon.l...x2e56310>', "<class 'gluon.languages.translator'>")
cache :
('<gluon.c...x2e56790>', "<class 'gluon.cache.Cache'>")
local_import :
('<functio...x2e52230>', "<type 'function'>")
redirect :
('<functio...x13229b0>', "<type 'function'>")
request :
('<Storage...age {}>}>', "<class 'gluon.globals.Request'>")
response :
("<Storage...x.html'}>", "<class 'gluon.globals.Response'>")
session :
('<Storage {}>', "<class 'gluon.globals.Session'>")

 

Related slices

Comments (3)


Hosting graciously provided by:
Python Anywhere