Package gluon :: Module main
[hide private]
[frames] | no frames]

Module main

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)

The gluon wsgi application ---------------------------

Classes [hide private]
  LazyWSGI
  HttpServer
the web2py web server (Rocket)
Functions [hide private]
 
get_client(env)
Guesses the client address from the environment variables
source code
 
serve_controller(request, response, session)
This function is used to generate a dynamic page.
source code
 
wsgibase(environ, responder)
The gluon wsgi application.
source code
 
save_password(password, port)
Used by main() to save the password in the parameters_port.py file.
source code
 
appfactory(wsgiapp=<function wsgibase at 0x3c73e60>, logfilename='httpserver.log', profiler_dir=None, profilerfilename=None)
generates a wsgi application that does logging and profiling and calls wsgibase
source code
Variables [hide private]
  web2py_path = '/home/mdipierro/make_web2py/web2py'
  logpath = '/home/mdipierro/make_web2py/web2py/logging.conf'
  logger = logging.getLogger("web2py")
  requests = 0
  regex_client = re.compile(r'[\w-:]+(\.[\w-]+)*\.?')
  version_info = open(pjoin(global_settings.gluon_parent, 'VERSI...
  raw_version_string = '2.9.5-stable+timestamp.2014.03.16.02.35.39'
  web2py_version = '2.9.5-stable+timestamp.2014.03.16.02.35.39'
  HTTPS_SCHEMES = set(['HTTPS', 'https'])
  __package__ = 'gluon'
Function Details [hide private]

get_client(env)

source code 

Guesses the client address from the environment variables

First tries 'http_x_forwarded_for', secondly 'remote_addr' if all fails, assume '127.0.0.1' or '::1' (running locally)

serve_controller(request, response, session)

source code 

This function is used to generate a dynamic page. It first runs all models, then runs the function in the controller, and then tries to render the output using a view/template. this function must run from the [application] folder. A typical example would be the call to the url /[application]/[controller]/[function] that would result in a call to [function]() in applications/[application]/[controller].py rendered by applications/[application]/views/[controller]/[function].html

wsgibase(environ, responder)

source code 

The gluon wsgi application. The first function called when a page
is requested (static or dynamic). It can be called by paste.httpserver
or by apache mod_wsgi (or any WSGI-compatible server).

  - fills request with info
  - the environment variables, replacing '.' with '_'
  - adds web2py path and version info
  - compensates for fcgi missing path_info and query_string
  - validates the path in url

The url path must be either:

1. for static pages:

  - /<application>/static/<file>

2. for dynamic pages:

  - /<application>[/<controller>[/<function>[/<sub>]]][.<extension>]

The naming conventions are:

  - application, controller, function and extension may only contain
    `[a-zA-Z0-9_]`
  - file and sub may also contain '-', '=', '.' and '/'

appfactory(wsgiapp=<function wsgibase at 0x3c73e60>, logfilename='httpserver.log', profiler_dir=None, profilerfilename=None)

source code 

generates a wsgi application that does logging and profiling and calls
wsgibase

Args:
    wsgiapp: the base application
    logfilename: where to store apache-compatible requests log
    profiler_dir: where to store profile files


Variables Details [hide private]

version_info

Value:
open(pjoin(global_settings.gluon_parent, 'VERSION'), 'r')