def default(self, *args, **kw): page = Page(str(self.dbsess)) page.addMenu() page.append(html.P('args=' + repr(args))) page.append(html.P('kw=' + repr(kw))) page.addFooter() return str(page)
def main(args): root_url = args[0] report_list_file = urllib.urlopen(root_url + '/' + args[1]) report_list = [] for line in report_list_file: line = line.strip() report_list.append(root_url + '/' + line) htTable = ht.TABLE() for i in range(5): report = PackageReport(report_list[i]) ##print report htTable.append(report.toHtml()) print ht.HTML(ht.BODY(htTable))
def addMenu(self): div = html.DIV(klass="menu") self.append(div) p = html.P("Menu:") div.append(p) p.append(html.BR()) p.append(html.A("home", href="/")) p.append(html.BR()) p.append(html.A("foo", href="foo/bar/baz")) p.append(html.BR()) p.append(html.A("reports", href="report"))
def report(self, *args,**kw): doc=self.beginResponse(title="report()") if len(args) > 0: tcl=self.dbsess.getTableClass(args[0]) if tcl is not None: self.dbsess.showViewGrid(tcl,*args[1:],**kw) else: self.dbsess.warning("%s : no such table",args[0]) #doc.append(html.P(args[0]+" : no such table")) return self.endResponse() list=html.UL(); doc.append(list) for table in self.dbsess.db.app.getTableList(): li=html.LI() ; list.append(li) li.append(html.A(table.getLabel(), href="report/"+table.getTableName())) li.append(" (%d rows)" % len(self.dbsess.query(table._instanceClass))) return self.endResponse()
def toHtml(self): """Eventually, this method will return the HTML text for representing this report as an HTML table row """ tableRow = ht.TR() tableRow.append(ht.TD(self.name)) tableRow.append(ht.TD(self.version)) ## FIXME: want to use CSS classes and not define color explicitly status = ht.FONT(self.status, color=self.statusColor) tableRow.append(ht.TD(ht.A(status, href=self.outputUrl))) return tableRow
def showReport(doc, rpt): rpt.setupReport() table = html.TABLE(title=rpt.getTitle()) doc.append(table) tr = html.TR() table.append(tr) for col in rpt.columns: tr.append(html.TH(col.getLabel())) for row in rpt: tr = html.TR() table.append(tr) for col in rpt.columns: v = col.getCellValue(row) if v is None: tr.append(html.TD(" ")) else: s = text2html(col.format(v).decode()) tr.append(html.TD(s))
def renderButton(self,btn): if btn.enabled: self.append(html.A(label2txt(btn.getLabel()), href=cherrypy.request.path+"/"+btn.name)) else: self.append(btn.label2txt(getLabel()))
def p(self,txt): self.append(html.P(txt))
def index(self): doc = self.beginResponse(title="index()") doc.append(html.P("This is the top-level page")) return self.endResponse()
def addFooter(self): div = html.DIV(klass="footer") self.append(div) div.append(html.P("foo " + cherrypy.request.base + " bar"))
def setup(self): div = html.DIV(klass="title") self.append(div) div.append(html.H1(self.title))
def __init__(self, title, *args, **kw): self.title = html.TITLE(title) Document.__init__(self, *args, **kw)