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 default(self,*args,**kw): frm=self.mainForm if len(args) >= 2: mnu=frm.menuBar.findMenu(args[0]) mi=mnu.findItem(args[1]) mi.click() frm=self.toolkit._formStack[-1] if len(args) >= 3: m=getattr(frm,args[2]) m(*args[3:]) frm=self.toolkit._formStack[-1] title=str(frm.getLabel()) doc=Document(title=html.TITLE(title)) div = html.DIV(klass="title") doc.append(div) div.append(html.H1(title)) div = html.DIV(klass="menu") doc.append(div) p = html.P("Menu:") div.append(p) if frm.menuBar is not None: for mnu in frm.menuBar.menus: p.append(html.BR()) #p.append(html.A(mnu.getLabel(),href=mnu.name)) p.append(label2txt(mnu.getLabel())) for mi in mnu.items: p.append(html.BR()) p.append(" · ", html.A(label2txt(mi.getLabel()), href=mnu.name+"/"+mi.name)) frm.mainComp.render(doc) #doc.append(html.HR()) #doc.append(html.P(self.dbsess.app.aboutString())) #doc.append(html.P('args='+repr(args))) #doc.append(html.P('kw='+repr(kw))) # div = html.DIV(klass="footer") doc.append(div) div.append(html.P("foo "+cherrypy.request.base + " bar")) return str(doc)
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: rpt = self.dbsess.getViewReport(tcl, *args[1:], **kw) showReport(doc, rpt) else: 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 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"))