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

5.1. Data structures for the regional index page

Aside from various form controls, the regional index is a sequence of entries, one per unique name that has been used for a circle that is all or partially in that region.

Given a region code and the CBC database, we can represent everything on the regional index page by three classes:


This class provides a uniform interface for primary and secondary entries so that they can be placed into a heterogeneous list, and then sorted using the built-in Python .sort() method.

This base class also defines an abstract method .html() that subclasses will use to build the actual XHTML of the index page.


Represents a primary entry. Contains an instance of the Circle class of the CBC database.


Represents a secondary entry. Contains the related Circle instance and the variant name.

This makes construction of the regional index page straightforward:

  1. Create an empty page and an empty list.

  2. For every row in the circle table, create a PrimaryEntry for that circle, and add that to the list.

  3. For every row, also look through the related rows of the effort table, and for each one that has a different name, create a SecondaryEntry for the primary circle and that name, and add that to the list.

  4. Sort the list.

  5. For each element of the sorted list, invoke its .html() method to add the appropriate XHTML to the page.

  6. Serialize the XHTML page.