def test_template_numbers(self): """ Data returned from a plated method may include numeric types (integers, floats, and possibly longs), which although they are not normally serializable by twisted.web.template, will be converted by plating into their decimal representation. """ @page.routed( self.app.route("/"), tags.div( tags.span(slot("anInteger")), tags.i(slot("anFloat")), tags.b(slot("anLong")), ), ) def plateMe(result): return {"anInteger": 7, "anFloat": 3.2, "anLong": 0x10000000000000001} request, written = self.get(b"/") self.assertIn(b"<span>7</span>", written) self.assertIn(b"<i>3.2</i>", written) self.assertIn(b"<b>18446744073709551617</b>", written)
def test_template_numbers(self): """ Data returned from a plated method may include numeric types (integers, floats, and possibly longs), which although they are not normally serializable by twisted.web.template, will be converted by plating into their decimal representation. """ @page.routed( self.app.route("/"), tags.div( tags.span(slot("anInteger")), tags.i(slot("anFloat")), tags.b(slot("anLong")), ), ) def plateMe(result): return { "anInteger": 7, "anFloat": 3.2, "anLong": 0x10000000000000001 } request, written = self.get(b"/") self.assertIn(b"<span>7</span>", written) self.assertIn(b"<i>3.2</i>", written) self.assertIn(b"<b>18446744073709551617</b>", written)
def logentries(self, request, tag): logdata = yield self.get_log() rv = [tag.clone().fillSlots( timestamp=tags.b("Fill Time"), cryo_name=tags.b("Cryo"), comments=tags.b("Comments"))] for entry in logdata: timestamp = entry[0] cryo_name = entry[1] if self.cryo_name.lower() not in cryo_name.lower(): continue comments = entry[2] try: # convert to human readable date timestamp = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%f').ctime() except ValueError: pass rv.append(tag.clone().fillSlots(timestamp=timestamp, cryo_name=cryo_name, comments=tags.pre(comments))) returnValue(rv)
def logentries(self, request, tag): logdata = yield self.get_log() rv = [ tag.clone().fillSlots(timestamp=tags.b("Fill Time"), cryo_name=tags.b("Cryo"), comments=tags.b("Comments")) ] for entry in logdata: timestamp = entry[0] cryo_name = entry[1] if self.cryo_name.lower() not in cryo_name.lower(): continue comments = entry[2] try: # convert to human readable date timestamp = datetime.datetime.strptime( timestamp, '%Y-%m-%dT%H:%M:%S.%f').ctime() except ValueError: pass rv.append(tag.clone().fillSlots(timestamp=timestamp, cryo_name=cryo_name, comments=tags.pre(comments))) returnValue(rv)
def getDropdown(self, title, url, cssClass): elements = [] if title == "About": links = urls.aboutDropDown for text, url, type in links: if type == const.DIVIDER: element = tags.li(class_="divider") elif type == const.HEADER: element = tags.li(text, class_="nav-header") else: element = tags.li(tags.a(text, href=url)) elements.append(element) return tags.li( tags.a( title, tags.b(class_="caret"), href="#", class_="dropdown-toggle", **{"data-toggle": "dropdown"}), tags.ul(elements, class_="dropdown-menu"), class_=cssClass)
def getDropdown(self, title, url, cssClass): elements = [] if title == "About": links = urls.aboutDropDown for text, url, type in links: if type == const.DIVIDER: element = tags.li(class_="divider") elif type == const.HEADER: element = tags.li(text, class_="nav-header") else: element = tags.li(tags.a(text, href=url)) elements.append(element) return tags.li(tags.a(title, tags.b(class_="caret"), href="#", class_="dropdown-toggle", **{"data-toggle": "dropdown"}), tags.ul(elements, class_="dropdown-menu"), class_=cssClass)
def footer(self,request,tag): return tag(tags.b('Footer.'))
def header(self, request, tag): return tag(tags.p(tags.b("Header")), id="header")
def header(self, request, tag): return tag(tags.b("Header."))
def header(self,request,tag): return tag(tags.b('Header'))
def header(self, request, tag): tdata = self.bucket.tdata title = 'Address: {network} » {gateway} » {node}'.format(**dict(tdata)) return tag(tags.b(title))
def footer(self, request, tag): return tag(tags.b("Footer."))
def header(self, request, tag): return tag(tags.b('Header.'))
def footer(self, request, tag): return tag(tags.b('Footer.'))