Next / Previous / Contents / TCC Help System / NM Tech homepage

Abstract

Describes a Python-language module for the generation of static and dynamic Web pages in the New Mexico Tech Computer Center's style.

This publication is available in Web form and also as a PDF document. Please forward any comments to tcc-doc@nmt.edu.

Table of Contents

1. Introduction
2. Overview
3. The XHTML to be generated
4. tccpage2test: A small test driver
5. Code prologue
6. Manifest constants
6.1. XHTML_DOCTYPE: Document type declaration for XHTML
6.2. XHTML_NS: The XHTML namespace URI
6.3. CSS_URL: Stylesheet location
6.4. TOP_NAV_SEP: Separator string for the top navigational bar
6.5. TCC_MAIN_URL: TCC mainpage URL
6.6. TCC_LOGO_URL: TCC logo URL
6.7. BOT_NAV_SEP: Separator for page-bottom links
7. addTextMixed(): Generating mixed content with lxml
8. class TCCPage: The page instance interface
8.1. TCCPage.__init__(): Constructor
8.2. TCCPage.__createHead(): Set up page heading
8.3. TCCPage.__createBody(): Set up page body
8.4. TCCPage.__topNav(): Set up top nav bar
8.5. TCCPage.__topNavItem(): Add one top navigational item
8.6. TCCPage.__titleBlock(): Set up page title block
8.7. TCCPage.__botNav(): Set up page-bottom navigational links
8.8. TCCPage.__botNavItem(): Generate page-bottom navigational link
8.9. TCCPage.__botNavShort(): Generate a short-form bottom nav link
8.10. TCCPage.__botNavGeneral(): Generate a general bottom nav link
8.11. TCCPage.__colophon(): Add colophon section
8.12. TCCPage.write(): Output the finished page
9. class NavLink: Describes one navigational feature

1. Introduction

The PyStyler application is used to maintain the bulk of the pages in the Tech Computer Center page structure and the TCC Help System. This application is rather antiquated, the design substantially stable since 1996; see Building informational webs with PyStyler (PDF format) for user-level documentation.

One major limitation of this system is that it treats its web pages as static structure, to be maintained with an ordinary text editor.

A number of TCC scripts generate Web pages outside the PyStyler system. Some scripts generate one or more static pages; other scripts are CGI scripts that generate pages dynamically in response to user requests. Ideally, PyStyler should be rewritten so that its content template can be applied easily to dynamically generate pages as well as to static pages inside a PyStyler document tree. This is a fairly sizeable project, however.

Here, we describe a Python module named tccpage2.py that is intended for use by Python scripts that generate web pages. Its purpose is to mimic the appearance of pages generated by PyStyler so that they blend visually with static pages.

Warning

Here's why this is a short-term solution. The PyStyler system uses a template file named Template to describe the overall layout of a TCC page. The templates used in the TCC web and TCC help web haven't changed much lately, so they're the basis of the style imitated by the tccpage2.py module. But if in the future we want to modify these templates, we'll have to modify the logic in the tccpage2.py module in parallel. The best long-term solution is to do a whole new version of PyStyler that has a single source for template information that can drive both static and dynamic page generation.

This package is called tccpage2.py because it is a rewrite of an earlier package, described in tccpage.py: Dynamic generation of TCC-style web pages.

Files generated from this document: