The purpose of this class is to define two behaviors common to both primary and secondary index entries:
Define how an index entry is rendered into XHTML.
Allow the sorting of a list containing a mixture of primary and secondary entries into ascending order by name.
Here is the interface definition.
# - - - - - c l a s s B a s e I n d e x
class BaseIndex(object):
'''Base class for index entries in the regional page.
Exports:
BaseIndex(db, cir_name, lat, lon):
[ (db is a pycbc.CBCData instance) and
(key is a circle name) and
(lat and lon are a circle's center coordinates) ->
return a new BaseIndex instance that sorts by
(cir_name, lat, lon) ]
.db: [ as passed to constructor, read-only ]
.cir_name: [ as passed to constructor, read-only ]
.lat: [ as passed to constructor, read-only ]
.lon: [ as passed to constructor, read-only ]
.html(parent): # Virtual method
[ parent is an et.Element ->
parent := parent with new XHTML added representing
self with a link that calls hist.cgi to produce
a report for just self's center ]
.__cmp__():
[ the usual comparison method, ascending on cir_name ]
'''
def html(self, parent):
'''Produce XHTML.
'''
raise NotImplentedError("BaseIndex.html() is a virtual method.")