Package qm :: Module web :: Class DtmlPage
[hide private]
[frames] | no frames]

Class DtmlPage

source code

Known Subclasses:

Base class for classes to generate web pages from DTML.

The 'DtmlPage' object is used as the variable context when generating HTML from DTML. Attributes and methods are available as variables in DTML expressions.

This base class contains common variables and functions that are available when generating all DTML files.

To generate HTML from a DTML template, instantiate a 'DtmlPage' object, passing the name of the DTML template file to the initializer function (or create a subclass which does this automatically). Additional named attributes specified in the initializer functions are set as attributes of the 'DtmlPage' object, and thus available as variables in DTML Python expressions.

To generate HTML from the template, use the '__call__' method, passing a 'WebRequest' object representing the request in response to which the HTML page is being generated. The request set as the 'request' attribute of the 'DtmlPage' object. The 'WebRequest' object may be omitted, if the generated HTML page is generic and requires no information specific to the request or web session; in this case, an empty request object is used.

This class also has an attribute, 'default_class', which is the default 'DtmlPage' subclass to use when generating HTML. By default, it is initialized to 'DtmlPage' itself, but applications may derive a 'DtmlPage' subclass and point 'default_class' to it to obtain customized versions of standard pages.

Nested Classes [hide private]
  default_class
Base class for classes to generate web pages from DTML.
Instance Methods [hide private]
 
__init__(self, dtml_template, **attributes)
Create a new page.
source code
 
__call__(self, request=None)
Generate an HTML page from the DTML template.
source code
 
GetProgramName(self)
Return the name of this application program.
source code
 
GetMainPageUrl(self)
Return the URL for the main page.
source code
 
WebRequest(self, script_url, **fields)
Convenience constructor for 'WebRequest' objects.
source code
 
GenerateXMLHeader(self)
Return the XML header for the document.
source code
 
GenerateHtmlHeader(self, description, headers='')
Return the header for an HTML document.
source code
 
GenerateStartBody(self, decorations=1)
Return markup to start the body of the HTML document.
source code
 
GenerateEndBody(self, decorations=1)
Return markup to end the body of the HTML document.
source code
 
GenerateStartScript(self, uri=None)
Return the HTML for beginning a script.
source code
 
GenerateEndScript(self)
Return the HTML for ending an embedded script.
source code
 
MakeLoginForm(self, redirect_request=None, default_user_id='') source code
 
MakeButton(self, title, script_url, css_class=None, **fields)
Generate HTML for a button to load a URL.
source code
 
MakeImageUrl(self, image)
Generate a URL for an image.
source code
 
MakeSpacer(self, width=1, height=1)
Generate a spacer.
source code
 
MakeRule(self, color='black')
Generate a plain horizontal rule.
source code
 
UserIsInGroup(self, group_id)
Return true if the user is a member of group 'group_id'.
source code
Class Variables [hide private]
  html_stylesheet = '/stylesheets/qm.css'
The URL for the cascading stylesheet to use with generated pages.
  common_javascript = '/common.js'
  qm_bug_system_url = 'mailto:qmtest@codesourcery.com'
The public URL for the bug tracking system for the QM tools.
  web
Common code for implementing web user interfaces.
Method Details [hide private]

__init__(self, dtml_template, **attributes)
(Constructor)

source code 

Create a new page.

'dtml_template' -- The file name of the DTML template from which the page is generated. The file is assumed to reside in the 'dtml' subdirectory of the configured share directory.

'**attributes' -- Additional attributes to include in the variable context.

__call__(self, request=None)
(Call operator)

source code 

Generate an HTML page from the DTML template.

'request' -- A 'WebRequest' object containing a page request in response to which an HTML page is being generated. Session information from the request may be used when generating the page. The request may be 'None', if none is available.

returns -- The generated HTML text.

WebRequest(self, script_url, **fields)

source code 

Convenience constructor for 'WebRequest' objects.

Constructs a 'WebRequest' using the specified 'script_url' and 'fields', using the request associated with this object as the base request.

GenerateHtmlHeader(self, description, headers='')

source code 

Return the header for an HTML document.

'description' -- A string describing this page.

'headers' -- Any additional HTML headers to place in the '<head>' section of the HTML document.

GenerateStartScript(self, uri=None)

source code 

Return the HTML for beginning a script.

'uri' -- If not None, a string giving the URI of the script.

returns -- A string consisting of HTML for beginning an embedded script.

'GenerateEndScript' must be called later to terminate the script.

GenerateEndScript(self)

source code 

Return the HTML for ending an embedded script.

returns -- A string consisting of HTML for ending an embedded script.

MakeButton(self, title, script_url, css_class=None, **fields)

source code 

Generate HTML for a button to load a URL.

'title' -- The button title.

'script_url' -- The URL of the script.

'fields' -- Additional fields to add to the script request.

'css_class' -- The CSS class to use for the button, or 'None'.

The resulting HTML must be included in a form.

MakeSpacer(self, width=1, height=1)

source code 

Generate a spacer.

'width' -- The width of the spacer, in pixels.

'height' -- The height of the spacer, in pixels.

returns -- A transparent image of the requested size.

UserIsInGroup(self, group_id)

source code 

Return true if the user is a member of group 'group_id'.

Checks the group membership of the user associated with the current session.

If there is no group named 'group_id' in the user database, returns a false result.


Class Variable Details [hide private]

web

Common code for implementing web user interfaces.

Value:
qm.web