durusmail: qp: Re: qpy development ideas
qpy development ideas
2007-10-08
2007-10-09
Re: qpy development ideas
2007-10-10
2007-10-10
2007-10-14
2007-10-15
David K. Hess (2 parts)
2007-10-09
2007-10-09
2007-10-10
2007-10-10
2007-10-10
2007-10-10
2007-10-10
Re: qpy development ideas
David K. Hess
2007-10-17
I like the idea of output formatting. The way I use qpy templates I
end up with pretty unreadable XHTML on the client when you view
source. That makes it more difficult to debug layout issues during
development.

Here's a patch to the previous slash.qpy that pretty prints the XHTML
doc before it heads to the client.

--- slash.qpy.orig      2007-10-16 12:06:27.000000000 -0500
+++ slash.qpy   2007-10-16 13:43:19.000000000 -0500
@@ -23,14 +23,15 @@
              page_text = "".join(xml)
              if get_config_value("parse_xml", False):
                  from lxml import etree
+                from cStringIO import StringIO
                  if not validate:
-                    etree.fromstring(page_text)
+                    doc = etree.parse(StringIO(page_text))
                  else:
                      parser = etree.XMLParser(dtd_validation=True)
-                    etree.fromstring(page_text, parser)
+                    doc = etree.parse(StringIO(page_text), parser)
                      if parser.error_log:
                          raise RuntimeError("Page failed to parse: "
+ str(parser.error_log))
-           return page_text
+           return doc.docinfo.doctype + "\n" + etree.tostring(doc,
pretty_print=True)
          return full_page
      return decorator

Dave

------
David K. Hess
Cell 214.684.5448 | Fax 214.764.7183
dhess@fishsoftware.com


On Oct 16, 2007, at 11:07 AM, Michael Watkins wrote:

> * David K. Hess wrote on [2007-10-15 15:27:17 -0500]:
>> I've attached a modification of the echo demo to demonstrate this
>> idea. It would be nice if this was just as doable if not easier with
>> a new version of qpy. The performance of course is terrible when
>> validating so you would never do this in production. Also, there is
>> probably some re-factoring that could/should be done.
>
> Another approach would be to crawl through the site; Dulcinea has a
> tool for validating HTML that might also be of interest:
>
> In the current version:
> http://www.mems-exchange.org/software/dulcinea/Dulcinea-0.17.tar.gz/
> Dulcinea-0.17/lib/ui/page_loader.py
>
> http://www.mems-exchange.org/software/dulcinea/
>
> Different than what David proposes I realize, just pointing it out
> for list readers.
>
> I seem to recall that Dulcinea (I believe it was Dulcinea, not QP)
> once had a per-request HTML tidy-based validation / output formatter
> mechanism once upon a time as well.
>
> Mike
> _______________________________________________
> QP mailing list
> QP@mems-exchange.org
> http://mail.mems-exchange.org/mailman/listinfo/qp
>


This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited. If you
are not the intended recipient, please contact the sender by reply email and
delete and destroy all copies of the original message.
reply