.

Page building: Dynamic pages

Preamble

There are two types of pages in Ensembl: static and dynamic. This page introduces the process by which the data objects and page elements of a dynamic page are created and displayed back to the user after a request to Apache. Other pages discuss the Apache request loop, and the configuration and session management in Ensembl.

Script handler calls

The Trans handler in the loop interprets the requested URL received from the browser. The following locations are searched for dynamic content scripts, in order of preference: If a dynamic script is found, it's location is sent to the Apache script handler which effectively runs the script via Perl. Ensembl uses mod_perl, which embeds Perl into Apache for performance and extensibility.

The dynamic page scripts can contain any valid Perl calls, however, in Ensembl, they are usually used to instantiate a new EnsEMBL::Web::Document::WebPage object. This class of object is responsible for managing the process of building a new response (usually in HTML) which is returned to the user.

Building a page with Document::WebPage

EnsEMBL::Web::Document::WebPage (or simply WebPage for brevity) is used by Ensembl to construct the web pages viewed by users. It is responsible for controlling the process of retrieving all required data from the Ensembl databases, formatting that data, generating images where necessary and collating all information together to be displayed to the user.

Fortunately, much of this complexity is compartmentalised into individual Perl modules (namely the Factory, Component, Configuration and Object families of classes) which WebPage manages and manipulates to create a reponse page. As such, a new web page can be created in Ensembl with a very simple script. For example, a new GeneView page is created with:
package geneview;

use EnsEMBL::Web::Document::WebPage;
simple_with_redirect( 'Gene' );

(simple_with_redirect create an object of type "Gene")

Renderers, output types and document types

Before looking at the process by which a new page is constructed, configured and displayed, it is worth considering three important parts of the WebPage machinery: The default values used by WebPage generate an HTML web page response to Apache. However, other response types are available.

The WebPage build pipeline

As seen above, a new GeneView page is constructed with a call to WebPage's simple_with_redirect(). This starts a production pipeline made up of the following stages:
  START
    ↓
  Initialise output 
    ↓
  Setup common output components
    ↓
  Retrieve data
    ↓
  Setup data specific output components
    ↓
  Collate and render
    ↓
  Delivery
GeneView produces an HTML page, delivered to a user's browser via Apache. Using this as an example, let's look at each stage:

Building other responses with Document::WebPage

EnsEMBL::Web::Document::WebPage is something of a misnomer. Whilst a standard plain text HTML response is commonly used by Ensembl, EnsEMBL::Web::Document::WebPage can return data in a number of other formats by replacing the default renderer, output type and document type.

Footnotes



 

© 2024 Inserm. Hosted by genouest.org. This product includes software developed by Ensembl.

                
GermOnline based on Ensembl release 50 - Jul 2008
HELP