def pdflatex_from_html(html): if os.system('which pdflatex > /dev/null') == 0: markmin = TAG(html).element('body').flatten(markmin_serializer) out, warnings, errors = markmin2pdf(markmin) if errors: current.response.headers['Content-Type'] = 'text/html' raise HTTP(405, HTML(BODY(H1('errors'), UL(*errors), H1('warnings'), UL(*warnings))).xml()) else: return XML(out)
def show_disabled(self, title): return HTML( HEAD( TITLE(title), LINK(_rel="shortcut icon", _href=URL('static', 'favicon.ico'), _type="image/x-icon")), BODY( DIV(CENTER( TABLE(TR( TD(IMG(_src=URL('static', 'images/dataprotection_min.jpg'), _style="border: solid;border-color: #FFFFFF;"), _style= "text-align: center;vertical-align: middle;font-weight: bold;font-family: Arial, Helvetica, sans-serif;font-size: 20px;" )), _style= "background-color:#FFFFFF;color:#444444;margin-top:30px;" )), _style="width:100%;height:100%;")), _style="background-color:#879FB7;")
def test_BODY(self): self.assertEqual( BODY('<>', _a='1', _b='2').xml(), b'<body a="1" b="2"><></body>')
def exportToReport(): if request.vars.database and request.vars.username: if request.vars.code in ("base64", "base64all"): if request.vars.password: password = base64.b64decode(request.vars.password) else: password = None validator = getLogin(base64.b64decode(request.vars.database), base64.b64decode(request.vars.username), password) else: if request.vars.password: password = request.vars.password else: password = None validator = getLogin(request.vars.database, request.vars.username, password) if validator["valid"] == False: return validator["message"] else: return T('Missing login parameter(s)!') params = {} filters = {} if request.vars.reportcode: if request.vars.code in ("base64", "base64all"): params["reportcode"] = base64.b64decode(request.vars.reportcode) else: params["reportcode"] = request.vars.reportcode elif request.vars.report_id: if request.vars.code in ("base64", "base64all"): params["report_id"] = base64.b64decode(request.vars.report_id) else: params["report_id"] = request.vars.report_id else: return T('Missing reportcode or report_id parameter!') if request.vars.filters: if request.vars.code in ("base64", "base64all"): filters = getParamList(base64.b64decode(request.vars.filters))[0] else: filters = getParamList(request.vars.filters)[0] else: return T('Missing filters parameter!') if request.vars.output: if request.vars.code in ("base64", "base64all"): params["output"] = base64.b64decode(request.vars.output) else: params["output"] = request.vars.output else: params["output"] = "html" if request.vars.orientation: if request.vars.code in ("base64", "base64all"): params["orientation"] = base64.b64decode(request.vars.orientation) else: params["orientation"] = request.vars.orientation else: params["orientation"] = "P" if request.vars.size: if request.vars.code in ("base64", "base64all"): params["size"] = base64.b64decode(request.vars.size) else: params["size"] = request.vars.size else: params["size"] = "A4" if params["output"] == "printer": if not request.vars.printername: return T('Missing printername parameter!') printer_prop = dbout.check_printer(request.vars.printername) if printer_prop["state"] == False: return printer_prop["error_message"] params["output"] = "pdf" if request.vars.copies: try: copies = int(request.vars.copies) except: copies = 1 else: copies = 1 else: printer_prop = None report_tmp = dbout.getReport(params, filters) if type(report_tmp).__name__ == "str": if report_tmp == "NODATA": return HTML( HEAD( TITLE("Nervatura Report"), LINK(_rel="shortcut icon", _href=URL('static', 'favicon.ico'), _type="image/x-icon")), BODY( DIV(CENTER( TABLE(TR( TD(IMG( _src=URL('static', 'images/nodata.png'), _style="border: solid;border-color: #FFFFFF;"), _style= "text-align: center;vertical-align: middle;font-weight: bold;font-family: sans-serif;font-size: 20px;" )), _style= "background-color:#FFFFFF;color:#444444;margin-top:200px;" )), _style="width:100%;height:100%")), _style="background-color:#000000;") else: return report_tmp if printer_prop: print_item = dbout.printReport(printer_prop, report_tmp["template"], "Nervatura Report", copies, params["orientation"], params["size"]) if print_item["state"] == False: return print_item["error_message"] return "OK" elif report_tmp["filetype"] == "ntr": if params["output"] == "xml": response.headers['Content-Type'] = 'text/xml' elif params["output"] == "pdf": response.headers['Content-Type'] = 'application/pdf' if request.vars.code == "base64all": return base64.b64encode(report_tmp["template"]) else: return report_tmp["template"] elif report_tmp["filetype"] == "xls": response.headers['Content-Type'] = "application/vnd.ms-excel" response.headers[ 'Content-Disposition'] = 'attachment;filename="NervaturaReport.xls"' if request.vars.code == "base64all": return base64.b64encode(report_tmp["template"]) else: return report_tmp["template"] elif report_tmp["filetype"] == "html": response.view = "default/report.html" response.title = report_tmp["data"]["title"] response.subtitle = "" import StringIO report_tmp["template"] = response.render( StringIO.StringIO(report_tmp["template"]), report_tmp["data"]) return dict(template=XML(report_tmp["template"])) else: if request.vars.code == "base64all": return base64.b64encode(report_tmp["template"]) else: return report_tmp["template"]
comment="some data"), formname=None, ) elif '--object' in sys.argv: form = OBJECT(TAG.PARAM(_name='label', _value='"test"'), TAG.PARAM(_name='name', _value='"btnTest"'), _class="Button", _width="100%", _height="80%") else: raise RuntimeError( "please use\npython forms_example.py --login, --form or --sqlform") form_xml = BODY(form, _text="#000000", _bgcolor="#bebec5", _link="#0000FF", _vlink="#FF0000", _alink="#000088").xml() print form_xml w.html.write(form_xml) #<form action="" enctype="multipart/form-data" method="post"><table><tr id="no_table_test__row"><td class="w2p_fl"><label for="no_table_test" id="no_table_test__label">Test: </label></td><td class="w2p_fw"><input class="string" id="no_table_test" name="test" type="text" value="" /></td><td class="w2p_fc">some data</td></tr><tr id="submit_record__row"><td class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit" /></td><td class="w2p_fc"></td></tr></table></form> #html.SetPage(search_html) #html.LoadFile(r"C:\htmlt.html") def on_form_submit(evt): print "Submitting to %s via %s with args %s" % ( evt.form.action, evt.form.method, evt.data) if form.accepts(evt.data, formname=None, keepvalues=True): print "accepted!"