7.9.2 RandomPageModuleMixin
This class inherits from the PageModuleMixin class. It
redefines the way in which page modules are selected.
Instead of the application calling the set_page() execution
context method, the URL in the browser request controls which page
module is loaded and processed for each request.
Page module management is inherited from PageModuleMixin. The
base_dir argument to the constructor determines the root
directory where modules are loaded from.
Page modules handled by this mixin have the following interface:
- page_enter(ctx)
-
If this function is present in the page module it will be called
every time the page module is used for a browser request.
The ctx argument contains the execution context.
- page_process(ctx)
-
If this function is present in the page module it will be called when
the application object executes the process_request() method.
This occurs if the browser request was successfully validated.
Refer to page in section 4.1 for
an overview of the application processing sequence.
- page_display(ctx)
-
This is the only mandatory page module function. The application
object calls this function when it executes the
display_response() method as the final step before saving the
browser session.
Refer to page in section 4.1 for
an overview of the application processing sequence.
The RandomPageModuleMixin class has the following interface.
- load_page(ctx)
-
This method implements part of the standard application processing
sequence. It is called immediately after restoring the browser
session. The ctx argument is the execution context for the
current browser request.
The method loads a page template and module by taking the page
identifier from the right hand side of the request URL. The page
identifier is then passed to the load_page_module() method
(which is inherited from PageModuleMixin).
Refer to page in section 4.1 for
an overview of the application processing sequence.
- load_badurl_template(ctx)
-
Called when your page template identified by the request URL does not
exist. The ctx argument is the execution context for the
current browser request.
Override this method if you want to supply a different error page
template.
- page_enter(ctx)
-
Called as soon as the page module has been loaded. The ctx
argument is the execution context for the current browser request.
The page module page_enter() function is called by this
method if a page module was located by the load_page()
method.
- process_request(ctx)
-
This method implements part of the standard application processing
sequence. It is called if the browser request is successfully
validated. The ctx argument is the execution context for the
current browser request.
The page module page_process() function is called by this
method if a page module was located by the load_page()
method.
Refer to page in section 4.1 for
an overview of the application processing sequence.
- display_response(ctx)
-
This method implements part of the standard application processing
sequence. It is called as the final stage just before the session is
saved. The ctx argument is the execution context for the
current browser request.
The page module page_display() function is called by this
method if a page module was located by the load_page()
method.
Refer to page in section 4.1 for
an overview of the application processing sequence.