Package gluon
[hide private]
[frames] | no frames]

Package gluon

source code

This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)

Web2Py framework modules

Submodules [hide private]
  • gluon.admin: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.cache: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.cache'
  • gluon.cfs: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.compileapp: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.contenttype: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.custom_import: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.dal: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.debug: | This file is part of the web2py Web Framework | Developed by Massimo Di Pierro <mdipierro@cs.depaul.edu>, | limodou <limodou@gmail.com> and srackham <srackham@gmail.com>.
  • gluon.decoder: Caller will hand this library a buffer and ask it to either convert it or auto-detect the type.
  • gluon.fileutils: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.globals: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.highlight: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.html: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.http: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.import_all: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.languages: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) | Plural subsystem is created by Vladyslav Kozlovskyy (Ukraine) <dbdevelop@gmail.com>
  • gluon.main: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.messageboxhandler
  • gluon.myregex: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.newcron: | This file is part of the web2py Web Framework | Created by Attila Csipa <web2py@csipa.in.rs> | Modified by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.portalocker: Cross-platform (posix/nt) API for flock-style file locking.
  • gluon.reserved_sql_keywords
  • gluon.restricted: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.rewrite: | This file is part of the web2py Web Framework | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.rocket
  • gluon.sanitizer: :
  • gluon.scheduler
  • gluon.serializers: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.settings: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.shell: This file is part of the web2py Web Framework Developed by Massimo Di Pierro <mdipierro@cs.depaul.edu>, limodou <limodou@gmail.com> and srackham <srackham@gmail.com>.
  • gluon.sql
  • gluon.sqlhtml: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.storage: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.streamer: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.template: This file is part of the web2py Web Framework (Copyrighted, 2007-2011).
  • gluon.tools: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.utf8: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.utils: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.validators: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.widget: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  • gluon.xmlrpc: This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu> License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)

Classes [hide private]
  A
Generates an A() link.
  B
  BEAUTIFY
Turns any list, dictionary, etc into decent looking html.
  BODY
  BR
  CAT
  CENTER
  CLEANUP
example:
  CODE
Displays code in HTML with syntax highlighting.
  CRYPT
example::
  DAL
an instance of this class represents a database connection
  DIV
HTML helper, for easy generating and manipulating a DOM structure.
  EM
  EMBED
  FIELDSET
  FORM
Examples:
  Field
  H1
  H2
  H3
  H4
  H5
  H6
  HEAD
  HR
  HTML
There are four predefined document type definitions.
  HTTP
Raises an HTTP response
  I
  IFRAME
  IMG
  INPUT
INPUT Component
  IS_ALPHANUMERIC
example:
  IS_DATE
example:
  IS_DATETIME
example:
  IS_DATETIME_IN_RANGE
example:
  IS_DATE_IN_RANGE
example:
  IS_DECIMAL_IN_RANGE
Determine that the argument is (or can be represented as) a Python Decimal, and that it falls within the specified inclusive range.
  IS_EMAIL
Checks if field's value is a valid email address.
  IS_EMPTY_OR
dummy class for testing IS_EMPTY_OR
  IS_EQUAL_TO
example:
  IS_EXPR
example:
  IS_FLOAT_IN_RANGE
Determine that the argument is (or can be represented as) a float, and that it falls within the specified inclusive range.
  IS_IMAGE
Checks if file uploaded through file input was saved in one of selected image formats and has dimensions (width and height) within given boundaries.
  IS_INT_IN_RANGE
Determine that the argument is (or can be represented as) an int, and that it falls within the specified range.
  IS_IN_DB
example:
  IS_IN_SET
example:
  IS_IPV4
Checks if field's value is an IP version 4 address in decimal form.
  IS_JSON
example:
  IS_LENGTH
Checks if length of field's value fits between given boundaries.
  IS_LIST_OF
  IS_LIST_OF_EMAILS
use as follows:...
  IS_LOWER
convert to lower case
  IS_MATCH
example:
  IS_NOT_EMPTY
example:
  IS_NOT_IN_DB
example:
  IS_NULL_OR
dummy class for testing IS_EMPTY_OR
  IS_SLUG
convert arbitrary text string to a slug
  IS_STRONG
example:
  IS_TIME
example:
  IS_UPLOAD_FILENAME
Checks if name and extension of file uploaded through file input matches given criteria.
  IS_UPPER
convert to upper case
  IS_URL
Rejects a URL string if any of the following is true: * The string is empty or None * The string uses characters that are not allowed in a URL * The string breaks any of the HTTP syntactic rules * The URL scheme specified (if one is specified) is not 'http' or 'https' * The top-level domain (if a host name is specified) does not exist
  LABEL
  LEGEND
  LI
  LINK
  MARKMIN
For documentation: http://web2py.com/examples/static/markmin.html
  MENU
Used to build menus
  META
  OBJECT
  OL
  OPTGROUP
  OPTION
  P
Will replace ``\n`` by ``<br />`` if the `cr2br` attribute is provided.
  PRE
  SCRIPT
  SELECT
Examples:
  SPAN
  SQLFORM
SQLFORM is used to map a table (and a current record) into an HTML form
  SQLTABLE
given a Rows object, as returned by a db().select(), generates an html table with the rows.
  STRONG
  STYLE
  TABLE
TABLE Component.
  TBODY
  TD
  TEXTAREA
Examples:
  TFOOT
  TH
  THEAD
  TITLE
  TR
TR Component.
  TT
  UL
UL Component.
  XHTML
This is XHTML version of the HTML helper.
  XML
use it to wrap a string that contains XML/HTML so that it will not be escaped by the template
Functions [hide private]
 
LOAD(c=None, f='index', args=None, vars=None, extension=None, target=None, ajax=False, ajax_trap=False, url=None, user_signature=False, timeout=None, times=1, content='loading...', **attr)
LOADs a component into the action's document
source code
 
URL(a=None, c=None, f=None, r=None, args=None, vars=None, anchor='', extension=None, env=None, hmac_key=None, hash_vars=True, salt=None, user_signature=None, scheme=None, host=None, port=None, encode_embedded_slash=False, url_encode=True, language=None)
generates a url '/a/c/f' corresponding to application a, controller c and function f.
source code
 
embed64(filename=None, file=None, data=None, extension='image/gif')
helper to encode the provided (binary) data into base64.
source code
 
redirect(location='', how=303, client_side=False)
Raises a redirect (303)
source code
Variables [hide private]
  ON = True
  T = translator(request)
  TAG = __TAG__()
  __package__ = 'gluon'
  auth = Auth(db)
  crud = Crud(db)
  current = None
  db = DAL()
  mail = Mail()
  plugins = PluginManager()
  request = Request()
  response = Response()
  service = Service()
  session = Session()
Function Details [hide private]

LOAD(c=None, f='index', args=None, vars=None, extension=None, target=None, ajax=False, ajax_trap=False, url=None, user_signature=False, timeout=None, times=1, content='loading...', **attr)

source code 
LOADs a component into the action's document

Args:
    c(str): controller
    f(str): function
    args(tuple or list): arguments
    vars(dict): vars
    extension(str): extension
    target(str): id of the target
    ajax(bool): True to enable AJAX bahaviour
    ajax_trap(bool): True if `ajax` is set to `True`, traps
        both links and forms "inside" the target
    url(str): overrides `c`,`f`,`args` and `vars`
    user_signature(bool): adds hmac signature to all links
        with a key that is different for every user
    timeout(int): in milliseconds, specifies the time to wait before
        starting the request or the frequency if times is greater than
        1 or "infinity"
    times(integer or str): how many times the component will be requested
        "infinity" or "continuous" are accepted to reload indefinitely the
        component

URL(a=None, c=None, f=None, r=None, args=None, vars=None, anchor='', extension=None, env=None, hmac_key=None, hash_vars=True, salt=None, user_signature=None, scheme=None, host=None, port=None, encode_embedded_slash=False, url_encode=True, language=None)

source code 

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('index')

that generates a url for the index function
within the present application and controller.

Args:
    a: application (default to current if r is given)
    c: controller (default to current if r is given)
    f: function (default to current if r is given)
    r: request (optional)
    args: any arguments (optional). Additional "path" elements
    vars: any variables (optional). Querystring elements
    anchor: anchorname, without # (optional)
    extension: force an extension
    hmac_key: key to use when generating hmac signature (optional)
    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']
    salt: salt hashing with this string
    user_signature: signs automatically the URL in such way that only the
        user can access the URL (use with `URL.verify` or
        `auth.requires_signature()`)
    scheme: URI scheme (True, 'http' or 'https', etc); forces absolute URL (optional)
    host: string to force absolute URL with host (True means http_host)
    port: optional port number (forces absolute URL)
    encode_embedded_slash: encode slash characters included in args
    url_encode: encode characters included in vars

Raises:
    SyntaxError: when no application, controller or function is available
        or when a CRLF is found in the generated url

Examples:

>>> 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=a32530f0d0caa80964bb92aad2bedf8a4486a31f#1'

>>> str(URL(a='a', c='c', f='f', args=['w/x', 'y/z']))
'/a/c/f/w/x/y/z'

>>> str(URL(a='a', c='c', f='f', args=['w/x', 'y/z'], encode_embedded_slash=True))
'/a/c/f/w%2Fx/y%2Fz'

>>> str(URL(a='a', c='c', f='f', args=['%(id)d'], url_encode=False))
'/a/c/f/%(id)d'

>>> str(URL(a='a', c='c', f='f', args=['%(id)d'], url_encode=True))
'/a/c/f/%25%28id%29d'

>>> str(URL(a='a', c='c', f='f', vars={'id' : '%(id)d' }, url_encode=False))
'/a/c/f?id=%(id)d'

>>> str(URL(a='a', c='c', f='f', vars={'id' : '%(id)d' }, url_encode=True))
'/a/c/f?id=%25%28id%29d'

>>> str(URL(a='a', c='c', f='f', anchor='%(id)d', url_encode=False))
'/a/c/f#%(id)d'

>>> str(URL(a='a', c='c', f='f', anchor='%(id)d', url_encode=True))
'/a/c/f#%25%28id%29d'

embed64(filename=None, file=None, data=None, extension='image/gif')

source code 

helper to encode the provided (binary) data into base64.

Args:
    filename: if provided, opens and reads this file in 'rb' mode
    file: if provided, reads this file
    data: if provided, uses the provided data

redirect(location='', how=303, client_side=False)

source code 
Raises a redirect (303)

Args:
    location: the url where to redirect
    how: what HTTP status code to use when redirecting
    client_side: if set to True, it triggers a reload of the entire page
      when the fragment has been loaded as a component