'Helper to produce a directory listing.
Return value is either a file object, or None (indicating an
error).  In either case, the headers are sent.'

def _list_directory(self, path, n):

    if ((not path.endswith('/')) and (len(path) > 0)):
        print ('Redirecting    from    %s    to    %s' % (path, (path + '/')))
        return self.redirect((path + '/'), permanent=True)
    try:
        show_hidden = int(self.request.arguments.get('hidden', [0])[(-1)])
    except ValueError as e:
        show_hidden = False
    self.render('list-directory.html', path=path, breadcrumbs=_compute_breadcrumbs(path, show_hidden), files_hidden=_contains_hidden_files(n), hidden_shown=show_hidden, dir_contents=_compute_dir_contents(n, path, show_hidden))
