Exemple #1
0
    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"))
Exemple #2
0
 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 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 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 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()))