def htCache(factory):
    'Output the cache of a servlet factory.'
    html = []
    wr = html.append
    cache = factory._classCache
    keys = sorted(cache)
    wr(('<p>Uniqueness: %s</p>' % factory.uniqueness()))
    wr(('<p>Extensions: %s</p>' % ', '.join(map(repr, factory.extensions()))))
    wr(('<p>Unique paths in the servlet cache: <strong>%d</strong> &nbsp; <input type="submit" name="flush_%s" value="Flush"></p>' % (len(keys), factory.name())))
    wr('<p>Click any link to jump to the details for that path.</p>')
    wr('<h5>Filenames:</h5>')
    wr('<table class="NiceTable">')
    wr('<tr><th>File</th><th>Directory</th></tr>')
    paths = []
    for key in keys:
        (head, tail) = os.path.split(key)
        path = dict(dir=head, base=tail, full=key)
        paths.append(path)
    paths.sort(key=(lambda p: (p['base'].lower(), p['dir'].lower())))
    for path in paths:
        wr(('<tr><td><a href="#id%s">%s</a></td><td>%s</td></tr>' % (id(path['full']), path['base'], path['dir'])))
    wr('</table>')
    wr('<h5>Full paths:</h5>')
    wr('<table class="NiceTable">')
    wr('<tr><th>Servlet path</th></tr>')
    for key in keys:
        wr(('<tr><td><a href="#%s">%s</a></td></tr>' % (id(key), key)))
    wr('</table>')
    wr('<h5>Details:</h5>')
    wr('<table class="NiceTable">')
    for path in paths:
        wr(('<tr class="NoTable"><td colspan="2"><a id="id%s"></a><strong>%s</strong> - %s</td></tr>' % (id(path['full']), path['base'], path['dir'])))
        record = cache[path['full']].copy()
        record['path'] = path['full']
        if (path['full'] in factory._threadsafeServletCache):
            record['instances'] = 'one servlet instance (threadsafe)'
        else:
            record['instances'] = ('free reusable servlets: %d' % len(factory._servletPool))
        wr(htRecord(record))
    wr('</table>')
    return '\n'.join(html)
Output the cache of a servlet factory.
def htCache(factory):
    
    html = []
    wr = html.append
    cache = factory._classCache
    keys = sorted(cache)
    wr(('<p>Uniqueness: %s</p>' % factory.uniqueness()))
    wr(('<p>Extensions: %s</p>' % ', '.join(map(repr, factory.extensions()))))
    wr(('<p>Unique paths in the servlet cache: <strong>%d</strong> &nbsp; <input type="submit" name="flush_%s" value="Flush"></p>' % (len(keys), factory.name())))
    wr('<p>Click any link to jump to the details for that path.</p>')
    wr('<h5>Filenames:</h5>')
    wr('<table class="NiceTable">')
    wr('<tr><th>File</th><th>Directory</th></tr>')
    paths = []
    for key in keys:
        (head, tail) = os.path.split(key)
        path = dict(dir=head, base=tail, full=key)
        paths.append(path)
    paths.sort(key=(lambda p: (p['base'].lower(), p['dir'].lower())))
    for path in paths:
        wr(('<tr><td><a href="#id%s">%s</a></td><td>%s</td></tr>' % (id(path['full']), path['base'], path['dir'])))
    wr('</table>')
    wr('<h5>Full paths:</h5>')
    wr('<table class="NiceTable">')
    wr('<tr><th>Servlet path</th></tr>')
    for key in keys:
        wr(('<tr><td><a href="#%s">%s</a></td></tr>' % (id(key), key)))
    wr('</table>')
    wr('<h5>Details:</h5>')
    wr('<table class="NiceTable">')
    for path in paths:
        wr(('<tr class="NoTable"><td colspan="2"><a id="id%s"></a><strong>%s</strong> - %s</td></tr>' % (id(path['full']), path['base'], path['dir'])))
        record = cache[path['full']].copy()
        record['path'] = path['full']
        if (path['full'] in factory._threadsafeServletCache):
            record['instances'] = 'one servlet instance (threadsafe)'
        else:
            record['instances'] = ('free reusable servlets: %d' % len(factory._servletPool))
        wr(htRecord(record))
    wr('</table>')
    return '\n'.join(html)