| 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 parses incoming URLs and formats outgoing URLs for
gluon.html.URL.
In addition, it rewrites both incoming and outgoing URLs based on the
(optional) user-supplied routes.py, which also allows for rewriting of
certain error messages.
routes.py supports two styles of URL rewriting, depending on whether
'routers' is defined. Refer to router.example.py and routes.example.py
for additional documentation.
|
_router_default()
Returns new copy of default base router |
source code
|
|
|
_params_default(app=None)
Returns a new copy of default parameters |
source code
|
|
|
log_rewrite(string)
Log rewrite activity under control of routes.py |
source code
|
|
|
|
|
url_in(request,
environ)
Parses and rewrites incoming URL |
source code
|
|
|
url_out(request,
environ,
application,
controller,
function,
args,
other,
scheme,
host,
port,
language=None)
Assembles and rewrites outgoing URL |
source code
|
|
|
try_rewrite_on_error(http_response,
request,
environ,
ticket=None)
Called from main.wsgibase to rewrite the http response. |
source code
|
|
|
try_redirect_on_error(http_object,
request,
ticket=None)
Called from main.wsgibase to rewrite the http response |
source code
|
|
|
load(routes=' routes.py ' ,
app=None,
data=None,
rdict=None)
load: read (if file) and parse routes store results in params (called
from main.py at web2py initialization time) If data is present, it's
used instead of the routes.py contents. |
source code
|
|
|
compile_regex(k,
v,
env=None)
Preprocess and compile the regular expressions in routes_app/in/out
The resulting regex will match a pattern of the form: |
source code
|
|
|
load_routers(all_apps)
Load-time post-processing of routers |
source code
|
|
|
regex_uri(e,
regexes,
tag,
default=None)
Filters incoming URI against a list of regexes |
source code
|
|
|
regex_select(env=None,
app=None,
request=None)
Selects a set of regex rewrite params for the current request |
source code
|
|
|
regex_filter_in(e)
Regex rewrite incoming URL |
source code
|
|
|
|
|
|
|
regex_url_in(request,
environ)
Rewrites and parses incoming URL |
source code
|
|
|
regex_filter_out(url,
e=None)
Regex rewrite outgoing URL |
source code
|
|
|
filter_url(url,
method=' get ' ,
remote=' 0.0.0.0 ' ,
out=False,
app=False,
lang=None,
domain=( None, None) ,
env=False,
scheme=None,
host=None,
port=None,
language=None)
doctest/unittest interface to regex_filter_in() and
regex_filter_out() |
source code
|
|
|
filter_err(status,
application=' app ' ,
ticket=' tkt ' )
doctest/unittest interface to routes_onerror |
source code
|
|
|
map_url_in(request,
env,
app=False)
Routes incoming URL |
source code
|
|
|
map_url_out(request,
env,
application,
controller,
function,
args,
other,
scheme,
host,
port,
language=None)
Supply /a/c/f (or /a/lang/c/f) portion of outgoing url |
source code
|
|
|
get_effective_router(appname)
Returns a private copy of the effective router for the specified
application |
source code
|
|
|
logger = logging.getLogger('web2py.rewrite')
|
|
THREAD_LOCAL = threading.local()
|
|
regex_at = re.compile(r'(?<! \\) \$[ a- zA- Z] \w* ')
|
|
regex_anything = re.compile(r'(?<! \\) \$anything')
|
|
regex_redirect = re.compile(r'( \d+ ) ->( .* ) ')
|
|
regex_full_url = re.compile(r'^(?P< scheme > http| https| HTTP| HTTP...
|
|
regex_version = re.compile(r'^( _\d+ \.\d+ \.\d+ ) $')
|
|
regex_url = re.compile(r'^/( (?P< a > \w+ ) ( /(?P< c > \w+ ) ( /(?P< z > (?P< ...
|
|
regex_args = re.compile(r'[ ^ \w/\.@=-] ')
|
|
params_apps = { }
|
|
params = <Storage {'routes_out': [], 'logging': 'off', 'name':...
|
|
routers = None
hash(x)
|
|
ROUTER_KEYS = set([ ' acfe_match ' , ' applications ' , ' args_match ' , ...
|
|
ROUTER_BASE_KEYS = set([ ' applications ' , ' default_application ' , ...
|
|
__package__ = ' gluon '
|