@auth.need_login
@webhelpers.setup_dbsession
def listtable(request, tablename=None):
    klass = get_model(tablename)
    resp = framework.ResponseDocument(request, doc_constructor,
             title="Table %s" % (tablename,))
    NM = resp.nodemaker
    resp.new_para(NM("A", {"href": request.get_url(addentry, tablename=tablename)},
            resp.get_icon("add")))
    cycler = itertools.cycle(["row1", "row2"]) # For alternating row styles.
    tbl = resp.doc.add_table(class_="sortable", width="100%")
    tbl.caption(tablename)
    colnames = models.get_rowdisplay(klass)
    tbl.new_headings("", *colnames)
    tbl.headings[0].class_ = "sorttable_nosort"
    tbl.new_footer("", *colnames)
    for dbrow in query(tablename, {}):
        row = tbl.new_row(id="rowid_%s" % dbrow.id, class_=cycler.next())
        col = row.new_column(
            NM("Fragments", {},
                NM("A", {"href": "edit/%s/" % (dbrow.id,)},
                    resp.get_small_icon("edit")),
                NM("A", {"href": "javascript:doDeleteRow(%r, %r);" % (tablename, dbrow.id)},
                    resp.get_small_icon("delete")),
            )
        )
        firstname = colnames[0]
        row.new_column(
            NM("A", {"href": request.get_url(view, tablename=tablename, rowid=dbrow.id)},
                    getattr(dbrow, firstname))
        )
        for colname in colnames[1:]:
            row.new_column(getattr(dbrow, colname))

    return resp.finalize()
dataset/ETHPy150Open kdart/pycopia/storage/pycopia/db/webservice.py/listtable/original