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.
Methods
|
|
|
|
GenerateEndBody
|
GenerateEndBody ( self, decorations=1 )
Return markup to end the body of the HTML document.
|
|
GenerateEndScript
|
GenerateEndScript ( self )
Return the HTML for ending an embedded script.
- returns
- A string consisting of HTML for ending an
embedded script.
|
|
GenerateHtmlHeader
|
GenerateHtmlHeader (
self,
description,
headers="",
)
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.
|
|
GenerateStartBody
|
GenerateStartBody ( self, decorations=1 )
Return markup to start the body of the HTML document.
|
|
GenerateStartScript
|
GenerateStartScript ( self, uri=None )
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.
|
|
GenerateXMLHeader
|
GenerateXMLHeader ( self )
Return the XML header for the document.
|
|
GetMainPageUrl
|
GetMainPageUrl ( self )
Return the URL for the main page.
|
|
GetProgramName
|
GetProgramName ( self )
Return the name of this application program.
|
|
MakeButton
|
MakeButton (
self,
title,
script_url,
css_class=None,
**fields,
)
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.
|
|
MakeImageUrl
|
MakeImageUrl ( self, image )
Generate a URL for an image.
|
|
MakeLoginForm
|
MakeLoginForm (
self,
redirect_request=None,
default_user_id="",
)
|
|
MakeRule
|
MakeRule ( self, color="black" )
Generate a plain horizontal rule.
|
|
MakeSpacer
|
MakeSpacer (
self,
width=1,
height=1,
)
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
|
UserIsInGroup ( self, group_id )
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.
|
|
WebRequest
|
WebRequest (
self,
script_url,
**fields,
)
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.
|
|
__call__
|
__call__ ( self, request=None )
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.
|
|
__init__
|
__init__ (
self,
dtml_template,
**attributes,
)
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.
|
|