7.10.3 PageObjectMixin

##
7.10.3 PageObjectMixin

This class is intended for applications which do not require a separate Python module for each page in the application. Page processing is performed by a set of objects which the application registers with this class. The class is designed to be used where the application controls the sequence of pages seen in a browser session so the start page is specified in the constructor.

Application page objects must be registered before they can be used. Typically you will register the page objects immediately after constructing your application object. Since the current application page is identified by an internal value, any hashable pickleable value can be used as an identifier.

Page objects handled by this mixin have the following interface:

page_enter( | ctx [, ...])

  If this method is present in the new page object it will be called whenever your application code changes current the page by calling the execution context `set_page()` method. For application types which define a start page this method is called in the start page when a new session is created.

  The ctx argument contains the execution context. Any extra arguments which are passed to the `set_page()` method are passed as optional extra arguments to this method.

page_leave( | ctx [, ...])

  If this method is present in the old page object it will be called whenever your application code changes current the page by calling the execution context `set_page()` method.

  The ctx argument contains the execution context.

page_process( | ctx)

  If this method is present in the page object 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 object function. The application object calls this method 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 `PageObjectMixin` class has the following interface.

`__init__`( | start_page)

  When you inherit from the `PageObjectMixin` class you must call this constructor.

  The start_page argument is a page identifier which specifies the first page that new browser session will see.

`module_path`( | )

  Returns `None`.

`start_page`( | )

  Returns the start_page argument which was passed to the constructor.

`register_page`( | name, obj)

  You must call this method to register every page object in your application. The name argument defines the page identifier which is used to select the page object specified in the obj argument. All pages must be registered before they can be used.

`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.

  If no current page is defined in ctx then the method will invoke `ctx.set_page()` passing the page specified as the start_page argument to the application constructor.

  Refer to page in section 4.1 for an overview of the application processing sequence.

`page_enter`( | ctx, args)

  Called when your application code calls the execution context `set_page()` method. The ctx argument is the execution context for the current browser request. The args argument is a tuple which contains all optional extra arguments which were passed to the `set_page()` method.

  The page object `page_enter()` method is called by this method.

`page_leave`( | ctx)

  Called before changing pages when your application code calls the execution context `set_page()` method. The ctx argument is the execution context for the current browser request.

  The page object `page_leave()` method is called by this 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 object `page_process()` method is called by this 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 object `page_display()` method is called by this method.

  Refer to page in section 4.1 for an overview of the application processing sequence.