def _setup_section(self, name, fields, rows): title = SimpleTitleElement(name) title.set_font(color='DarkViolet') td = TD() anchor = Anchor('new.%s.mtype' % name, 'new') td.appendChild(anchor) title.row.appendChild(td) self.body.appendChild(title) if len(rows): table = self._make_table(name, fields, rows, border=1, cellspacing=1) color_header(table, 'MediumOrchid2') self.body.appendChild(table)
def __init__(self, rows, **atts): BaseElement.__init__(self, 'table', **atts) for row in rows: trow = TR() fake_template = ',,,'.join([row.package, row.template.replace('.', ',')]) ta = Anchor('show.template.%s' % fake_template, row.template) td = TD() td.appendChild(ta) trow.appendChild(td) p = TxtTD(row.package) trow.appendChild(p) self.appendChild(trow)
def __init__(self, rows, **atts): BaseElement.__init__(self, "table", **atts) for row in rows: trow = TR() fake_template = ",,,".join([row.package, row.template.replace(".", ",")]) ta = Anchor("show.template.%s" % fake_template, row.template) td = TD() td.appendChild(ta) trow.appendChild(td) p = TxtTD(row.package) trow.appendChild(p) self.appendChild(trow)
def set_trait(self, trait): self.clear_body() self.trait.set_trait(trait) title = SimpleTitleElement('Trait: %s' % trait, bgcolor='IndianRed', width='100%') self.body.appendChild(title) self.body.appendChild(HR()) plist = UnorderedList() parents = self.trait.parents(trait=trait) parent_section = SectionTitle('Parents') parent_section.create_rightside_table() parent_section.append_rightside_anchor( Anchor('hello.there.dude', 'edit')) parent_section.append_rightside_anchor( Anchor('hello.there.dudee', 'edit2')) self.body.appendChild(parent_section) for parent in parents: pp = Anchor('show.parent.%s' % parent, parent) plist.appendChild(ListItem(pp)) self.body.appendChild(plist) #ptitle_anchor = Anchor('edit.packages.%s' % trait, 'Packages') ptitle = SectionTitle('Packages') ptitle_anchor = Anchor('new.package.%s' % trait, '(new)') td = TD() td.appendChild(ptitle_anchor) ptitle.row.appendChild(td) self.body.appendChild(ptitle) rows = self.trait.packages(trait=trait, action=True) self.body.appendChild(PackageTable(rows, bgcolor='SkyBlue3')) ttitle = Anchor('edit.templates.%s' % trait, 'Templates') self.body.appendChild(SectionTitle(ttitle)) rows = self.trait.templates( trait=trait, fields=['package', 'template', 'templatefile']) if len(rows): self.body.appendChild(TemplateTable(rows, bgcolor='DarkSeaGreen3')) self.body.appendChild(SectionTitle('Variables', href='foo.var.ick')) if len(self.trait.environ.keys()): env = TraitEnvTable(trait, self.trait.environ, bgcolor='MistyRose3') self.body.appendChild(env) self.body.appendChild(SectionTitle('Scripts')) slist = UnorderedList() for row in self.trait._scripts.scripts(trait=trait): script = row.script sa = Anchor('show.script.%s' % script, script) slist.appendChild(ListItem(sa)) self.body.appendChild(slist)
def set_trait(self, trait): self.clear_body() self.trait.set_trait(trait) title = SimpleTitleElement('Trait: %s' % trait, bgcolor='IndianRed', width='100%') self.body.appendChild(title) self.body.appendChild(HR()) plist = UnorderedList() parents = self.trait.parents(trait=trait) parent_section = SectionTitle('Parents') parent_section.create_rightside_table() parent_section.append_rightside_anchor(Anchor('hello.there.dude', 'edit')) parent_section.append_rightside_anchor(Anchor('hello.there.dudee', 'edit2')) self.body.appendChild(parent_section) for parent in parents: pp = Anchor('show.parent.%s' % parent, parent) plist.appendChild(ListItem(pp)) self.body.appendChild(plist) #ptitle_anchor = Anchor('edit.packages.%s' % trait, 'Packages') ptitle = SectionTitle('Packages') ptitle_anchor = Anchor('new.package.%s' % trait, '(new)') td = TD() td.appendChild(ptitle_anchor) ptitle.row.appendChild(td) self.body.appendChild(ptitle) rows = self.trait.packages(trait=trait, action=True) self.body.appendChild(PackageTable(rows, bgcolor='SkyBlue3')) ttitle = Anchor('edit.templates.%s' % trait, 'Templates') self.body.appendChild(SectionTitle(ttitle)) rows = self.trait.templates(trait=trait, fields=['package', 'template', 'templatefile']) if len(rows): self.body.appendChild(TemplateTable(rows, bgcolor='DarkSeaGreen3')) self.body.appendChild(SectionTitle('Variables', href='foo.var.ick')) if len(self.trait.environ.keys()): env = TraitEnvTable(trait, self.trait.environ, bgcolor='MistyRose3') self.body.appendChild(env) self.body.appendChild(SectionTitle('Scripts')) slist = UnorderedList() for row in self.trait._scripts.scripts(trait=trait): script = row.script p = Paragraph() sa = Anchor('show.script.%s' % script, script) ea = Anchor('edit.script.%s' % script, ' (edit)') p.appendChild(sa) p.appendChild(ea) slist.appendChild(ListItem(p)) self.body.appendChild(slist)
def set_trait(self, trait): self.clear_body() self.trait.set_trait(trait) title = SimpleTitleElement("Trait: %s" % trait, bgcolor="IndianRed", width="100%") self.body.appendChild(title) self.body.appendChild(HR()) plist = UnorderedList() parents = self.trait.parents(trait=trait) parent_section = SectionTitle("Parents") parent_section.create_rightside_table() parent_section.append_rightside_anchor(Anchor("hello.there.dude", "edit")) parent_section.append_rightside_anchor(Anchor("hello.there.dudee", "edit2")) self.body.appendChild(parent_section) for parent in parents: pp = Anchor("show.parent.%s" % parent, parent) plist.appendChild(ListItem(pp)) self.body.appendChild(plist) # ptitle_anchor = Anchor('edit.packages.%s' % trait, 'Packages') ptitle = SectionTitle("Packages") ptitle_anchor = Anchor("new.package.%s" % trait, "(new)") td = TD() td.appendChild(ptitle_anchor) ptitle.row.appendChild(td) self.body.appendChild(ptitle) rows = self.trait.packages(trait=trait, action=True) self.body.appendChild(PackageTable(rows, bgcolor="SkyBlue3")) ttitle = Anchor("edit.templates.%s" % trait, "Templates") self.body.appendChild(SectionTitle(ttitle)) rows = self.trait.templates(trait=trait, fields=["package", "template", "templatefile"]) if len(rows): self.body.appendChild(TemplateTable(rows, bgcolor="DarkSeaGreen3")) self.body.appendChild(SectionTitle("Variables", href="foo.var.ick")) if len(self.trait.environ.keys()): env = TraitEnvTable(trait, self.trait.environ, bgcolor="MistyRose3") self.body.appendChild(env) self.body.appendChild(SectionTitle("Scripts")) slist = UnorderedList() for row in self.trait._scripts.scripts(trait=trait): script = row.script sa = Anchor("show.script.%s" % script, script) slist.appendChild(ListItem(sa)) self.body.appendChild(slist)
def _add_table_row(self, table, fields, row): trow = TR() for field in fields: val = row[field] trow.appendChild(TxtTD(val)) durl = 'delete.%s.%s' % (table.context, row[fields[0]]) eurl = 'edit.%s.%s' % (table.context, row[fields[0]]) delanchor = Anchor(durl, 'delete') editanchor = Anchor(eurl, 'edit') td = TD() td.appendChild(editanchor) td.appendChild(BR()) td.appendChild(delanchor) trow.appendChild(td) #trow.appendChild(TxtTD(delanchor)) table.appendChild(trow)
def __init__(self, fields, idcol, action, record, **atts): BaseElement.__init__(self, 'table', **atts) self.record = record refdata = None if hasattr(record, '_refdata'): refdata = record._refdata for field in fields: row = BaseElement('tr') key = TD(bgcolor='DarkSeaGreen') key.appendChild(Bold(field)) row.appendChild(key) val = TD() if refdata is not None and field in refdata.cols: ridcol = refdata.cols[field] refrec = refdata.data[field][record[ridcol]] node = refdata.object[field](refrec) if action: url = '.'.join(map(str, [action, field, record[idcol]])) val.appendChild(Anchor(url, node)) else: val.appendChild(node) elif action: url = '.'.join(map(str, [action, field, record[idcol]])) val.appendChild(Anchor(url, record[field])) else: node = Text() node.data = record[field] val.appendChild(node) row.appendChild(val) self.val = val self.key = key self.appendChild(row)