shell
Module¶
Web2py environment in the shell¶
-
gluon.shell.
env
(a, import_models=False, c=None, f=None, dir='', extra_request={})[source]¶ Returns web2py execution environment for application (a), controller (c), function (f). If import_models is True the exec all application models into the environment.
extra_request allows you to pass along any extra variables to the request object before your models get executed. This was mainly done to support web2py_utils.test_runner, however you can use it with any wrapper scripts that need access to the web2py environment.
-
gluon.shell.
exec_environment
(pyfile='', request=None, response=None, session=None)[source]¶ Environment builder and module loader.
Builds a web2py environment and optionally executes a Python file into the environment.
A Storage dictionary containing the resulting environment is returned. The working directory must be web2py root – this is the web2py default.
-
gluon.shell.
parse_path_info
(path_info, av=False)[source]¶ Parses path info formatted like a/c/f where c and f are optional and a leading / is accepted. Return tuple (a, c, f). If invalid path_info a is set to None. If c or f are omitted they are set to None. If av=True, parse args and vars
-
gluon.shell.
run
(appname, plain=False, import_models=False, startfile=None, bpython=False, python_code=False, cronjob=False)[source]¶ Start interactive shell or run Python script (startfile) in web2py controller environment. appname is formatted like:
- a : web2py application name
- a/c : exec the controller c into the application environment
-
gluon.shell.
test
(testpath, import_models=True, verbose=False)[source]¶ Run doctests in web2py environment. testpath is formatted like:
- a: tests all controllers in application a
- a/c: tests controller c in application a
- a/c/f test function f in controller c, application a
Where a, c and f are application, controller and function names respectively. If the testpath is a file name the file is tested. If a controller is specified models are executed by default.