`` tags.
.. method:: Application.base_url()
Returns the *base_url* argument which was passed to the constructor.
.. method:: Application.run(req)
Implements the standard application run sequence as described in the
:ref:`app-model` section. The browser request passed as the *req* argument is
attached to the execution context as soon as the context has been created.
If an exception is caught then the :meth:`handle_exception` method is called
passing the *req* argument.
.. method:: Application.format_exception()
Retrieves the current exception from ``sys.exc_info()`` then formats and returns
the standard Python traceback and a template interpreter traceback.
.. method:: Application.handle_exception(ctx, req)
This implements the default exception handling for applications. The *req*
argument is the browser request which was passed to the :meth:`run` method.
The method calls the :meth:`format_exception` method to construct a standard
Python traceback and a template traceback. A temporary execution context is
then created, the Python traceback is saved in the :attr:`locals.python_exc`
value, and the template traceback in the :attr:`locals.html_exc` value.
The method then tries to load the ``'uncaught_exception.html'`` template
file and execute it with the temporary execution context. This gives you
the ability to control the presentation and reporting of exceptions.
If any exceptions are raised during the execution of
``'uncaught_exception.html'`` the method writes both formatted
exceptions as a ```` formatted browser response.
.. method:: Application.template_traceback(tb)
Generates a template interpreter traceback from the Python stack trace in the
*tb* argument.
.. method:: Application.load_session(ctx)
Calls the :meth:`load_session` method of the execution context in the *ctx*
argument.
.. method:: Application.save_session(ctx)
Calls the :meth:`save_session` method of the execution context in the *ctx*
argument.
.. method:: Application.remove_session(ctx)
Calls the :meth:`remove_session` method of the execution context in the *ctx*
argument.
.. method:: Application.validate_request(ctx)
Returns ``TRUE``.
You should override this method in your application object if you need to
validate browser requests before processing them. Returning False will prevent
the browser request being merged into the local namespace and the page_process
logic will not be called (see also the description of the Albatross Application
Model in :ref:`app-model`).
.. method:: Application.pickle_sign(text)
Returns an empty string to prevent insecure pickles being sent to the browser.
This is overridden in the :class:`PickleSignMixin` class.
.. method:: Application.pickle_unsign(text)
Returns an empty string to prevent insecure pickles being accepted from the
browser. This is overridden in the :class:`PickleSignMixin` class.
.. method:: Application.merge_request(ctx)
Calls the :meth:`merge_request` method of the execution context.
.. _pack-appclasses:
Application Classes:
====================
.. _pack-simpleapp:
The ``SimpleApp`` Class
-----------------------
The :class:`SimpleApp` class is intended for use in monolithic applications
(page objects instead of page modules). An inheritance diagram illustrates the
relationship to the :class:`SimpleAppContext` class described above.
.. _fig-simpleapp:
.. figure:: .build/figures/simpleapp.*
:align: center
The :class:`SimpleApp` class
The methods available in :class:`SimpleApp` and the location of their definition
are show below.
.. include:: .build/method-docs/SimpleApp-methods.rst
The :class:`SimpleApp` class defines the following methods:
.. method:: SimpleApp.__init__(base_url, template_path, start_page, secret)
When you inherit from the :class:`SimpleApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *template_path* defines the root directory where
template files are loaded from. The *start_page* identifies the first page that
will be served up in a new browser session. The *secret* argument is used to
sign all pickles sent to the browser.
.. method:: SimpleApp.create_context()
Returns a new instance of the :class:`SimpleAppContext` class.
.. _pack-simplesessapp:
The ``SimpleSessionApp`` Class
------------------------------
The :class:`SimpleSessionApp` class is intended for use in monolithic
applications (page objects instead of page modules). Session state is stored at
the server.
.. _fig-simplesessapp:
.. figure:: .build/figures/simplesessapp.*
:align: center
The :class:`SimpleSessionApp` class
The methods available in :class:`SimpleSessionApp` and the location of their
definition are show below.
.. include:: .build/method-docs/SimpleSessionApp-methods.rst
The :class:`SimpleSessionApp` class defines the following methods:
.. method:: SimpleSessionApp.__init__(base_url, template_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])
When you inherit from the :class:`SimpleSessionApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *template_path* defines the root directory where
template files are loaded from. The *start_page* identifies the first page that
will be served up in a new browser session. The *secret* argument is used to
sign all pickles sent to the browser.
The *session_appid* argument identifies the session application at the session
server. Multiple applications can share sessions by using the same identifier
here. The *session_server* argument defines the host where the session server
is running, it defaults to ``localhost``. The *server_port* defines the session
server port, it defaults to ``34343``. The *session_age* argument defines the
number of seconds that an idle session will be kept, it defaults to ``1800``.
.. method:: SimpleSessionApp.create_context()
Returns a new instance of the :class:`SessionAppContext` class.
.. _pack-simplesessfileapp:
The ``SimpleSessionFileApp`` Class
----------------------------------
The :class:`SimpleSessionFileApp` class is intended for use in monolithic
applications (page objects instead of page modules). Session state is stored in
the file system at the server.
.. _fig-simplesessfileapp:
.. figure:: .build/figures/simplesessfileapp.*
:align: center
The :class:`SimpleSessionFileApp` class
The methods available in :class:`SimpleSessionFileApp` and the location of their
definition are show below.
.. include:: .build/method-docs/SimpleSessionFileApp-methods.rst
The :class:`SimpleSessionFileApp` class defines the following methods:
.. method:: SimpleSessionFileApp.__init__(base_url, template_path, start_page, secret, session_appid, session_dir)
When you inherit from the :class:`SimpleSessionFileApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *template_path* defines the root directory where
template files are loaded from. The *start_page* identifies the first page that
will be served up in a new browser session. The *secret* argument is used to
sign all pickles sent to the browser.
The *session_appid* argument identifies the session application in the browser
cookie. Multiple applications can share sessions by using the same identifier
here. The *session_dir* argument defines the directory in which the application
will store session files.
.. method:: SimpleSessionFileApp.create_context()
Returns a new instance of the :class:`SessionFileAppContext` class.
.. _pack-modularapp:
The ``ModularApp`` Class
------------------------
The :class:`ModularApp` class is intended for use in applications which define
page code in a collection of Python modules.
.. _fig-modularapp:
.. figure:: .build/figures/modularapp.*
:align: center
The :class:`ModularApp` class
The methods available in :class:`ModularApp` and the location of their
definition are show below.
.. include:: .build/method-docs/ModularApp-methods.rst
The :class:`ModularApp` class defines the following methods:
.. method:: ModularApp.__init__(base_url, module_path, template_path, start_page, secret)
When you inherit from the :class:`ModularApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *module_path* argument defines the root directory
where page modules are loaded from. The *template_path* argument defines the
root directory where template files are loaded from. The *start_page*
identifies the first page that will be served up in a new browser session. The
*secret* argument is used to sign all pickles sent to the browser.
.. method:: ModularApp.create_context()
Returns a new instance of the :class:`SimpleAppContext` class.
.. _pack-modularsessapp:
The ``ModularSessionApp`` Class
-------------------------------
The :class:`ModularSessionApp` class is intended for use in applications which
define page code in a collection of Python modules. Session state is stored at
the server.
.. _fig-modularsessapp:
.. figure:: .build/figures/modularsessapp.*
:align: center
The :class:`ModularSessionApp` class
The methods available in :class:`ModularSessionApp` and the location of their
definition are show below.
.. include:: .build/method-docs/ModularSessionApp-methods.rst
The :class:`ModularSessionApp` class defines the following methods:
.. method:: ModularSessionApp.__init__(base_url, module_path, template_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])
When you inherit from the :class:`ModularSessionApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *module_path* argument defines the root directory
where page modules are loaded from. The *template_path* argument defines the
root directory where template files are loaded from. The *start_page*
identifies the first page that will be served up in a new browser session. The
*secret* argument is used to sign all pickles sent to the browser.
The *session_appid* argument identifies the session application at the session
server. Multiple applications can share sessions by using the same identifier
here. The *session_server* argument defines the host where the session server
is running, it defaults to ``localhost``. The *server_port* defines the session
server port, it defaults to ``34343``. The *session_age* argument defines the
number of seconds that an idle session will be kept, it defaults to ``1800``.
.. method:: ModularSessionApp.create_context()
Returns a new instance of the :class:`SessionAppContext` class.
.. _pack-modularsessfileapp:
The ``ModularSessionFileApp`` Class
-----------------------------------
The :class:`ModularSessionFileApp` class is intended for use in applications
which define page code in a collection of Python modules. Session state is
stored in the file system at the server.
.. _fig-modularsessfileapp:
.. figure:: .build/figures/modularsessfileapp.*
:align: center
The :class:`ModularSessionFileApp` class
The methods available in :class:`ModularSessionFileApp` and the location of
their definition are show below.
.. include:: .build/method-docs/ModularSessionFileApp-methods.rst
The :class:`ModularSessionFileApp` class defines the following methods:
.. method:: ModularSessionFileApp.__init__(base_url, module_path, template_path, start_page, secret, session_appid, session_dir)
When you inherit from the :class:`ModularSessionFileApp` class you must call
this constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *module_path* argument defines the root directory
where page modules are loaded from. The *template_path* argument defines the
root directory where template files are loaded from. The *start_page*
identifies the first page that will be served up in a new browser session. The
*secret* argument is used to sign all pickles sent to the browser.
The *session_appid* argument identifies the session application in the browser
cookie. Multiple applications can share sessions by using the same identifier
here. The *session_dir* argument defines the directory in which the application
will store session files.
.. method:: ModularSessionFileApp.create_context()
Returns a new instance of the :class:`SessionFileAppContext` class.
.. _pack-ranmodapp:
The ``RandomModularApp`` Class
------------------------------
The :class:`RandomModularApp` class is intended for use in applications which
define page code in a collection of Python modules which are randomly accessed
via the URI in the browser request.
.. _fig-randmodapp:
.. figure:: .build/figures/randmodapp.*
:align: center
The :class:`RandomModularApp` class
The methods available in :class:`RandomModularApp` and the location of their
definition are show below.
.. include:: .build/method-docs/RandomModularApp-methods.rst
The :class:`RandomModularApp` class defines the following methods:
.. method:: RandomModularApp.__init__(base_url, page_path, start_page, secret)
When you inherit from the :class:`RandomModularApp` class you must call this
constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *page_path* argument defines the root directory
where page modules and template files are loaded from. The *start_page*
identifies the page that will be served up when a page identifier cannot be
determined from the URI in the browser request. The *secret* argument is used
to sign all pickles sent to the browser.
.. method:: RandomModularApp.create_context()
Returns a new instance of the :class:`SimpleAppContext` class.
.. _pack-ranmodsessapp:
The ``RandomModularSessionApp`` Class
-------------------------------------
The :class:`RandomModularSessionApp` class is intended for use in applications
which define page code in a collection of Python modules which are randomly
accessed via the URI in the browser request. Session state is stored at the
server.
.. _fig-randmodsessapp:
.. figure:: .build/figures/randmodsessapp.*
:align: center
The :class:`RandomModularSessionApp` class
The methods available in :class:`RandomModularSessionApp` and the location of
their definition are show below.
.. include:: .build/method-docs/RandomModularSessionApp-methods.rst
The :class:`RandomModularSessionApp` class defines the following methods:
.. method:: RandomModularSessionApp.__init__(base_url, page_path, start_page, secret, session_appid [, session_server ``= 'localhost'``] [, server_port ``= 34343``] [, session_age ``= 1800``])
When you inherit from the :class:`RandomModularSessionApp` class you must call
this constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *page_path* argument defines the root directory
where page modules and template files are loaded from. The *start_page*
identifies the page that will be served up when a page identifier cannot be
determined from the URI in the browser request. The *secret* argument is used
to sign all pickles sent to the browser.
The *session_appid* argument identifies the session application at the session
server. Multiple applications can share sessions by using the same identifier
here. The *session_server* argument defines the host where the session server
is running, it defaults to ``localhost``. The *server_port* defines the session
server port, it defaults to ``34343``. The *session_age* argument defines the
number of seconds that an idle session will be kept, it defaults to ``1800``.
.. method:: RandomModularSessionApp.create_context()
Returns a new instance of the :class:`SessionAppContext` class.
.. _pack-ranmodsessfileapp:
The ``RandomModularSessionFileApp`` Class
-----------------------------------------
The :class:`RandomModularSessionFileApp` class is intended for use in
applications which define page code in a collection of Python modules which are
randomly accessed via the URI in the browser request. Session state is stored in
the file system at the server.
.. _fig-randmodsessfileapp:
.. figure:: .build/figures/randmodsessfileapp.*
:align: center
The :class:`RandomModularSessionFileApp` class
The methods available in :class:`RandomModularSessionFileApp` and the location
of their definition are show below.
.. include:: .build/method-docs/RandomModularSessionFileApp-methods.rst
The :class:`RandomModularSessionFileApp` class defines the following methods:
.. method:: RandomModularSessionFileApp.__init__(base_url, page_path, start_page, secret, session_appid, session_dir)
When you inherit from the :class:`RandomModularSessionFileApp` class you must
call this constructor.
The *base_url* argument is used as the base for URLs produced by the ````
and ```` tags. The *page_path* argument defines the root directory
where page modules and template files are loaded from. The *start_page*
identifies the page that will be served up when a page identifier cannot be
determined from the URI in the browser request. The *secret* argument is used
to sign all pickles sent to the browser.
The *session_appid* argument identifies the session application at the session
server. Multiple applications can share sessions by using the same identifier
here. The *session_dir* argument defines the directory in which the application
will store session files.
.. method:: RandomModularSessionFileApp.create_context()
Returns a new instance of the :class:`SessionFileAppContext` class.