What are people using for HTML validators?  I'm looking for something
that puts error messages in the page like the W3C online validator
does.    I assumed there would be a middleware but didn't find any, so
I tried making one based on uTidylib.  But it just deletes erroneous
tags rather than logging a message, and I'm also getting an error from
Pylons.

Here's the middleware:

import tidy

class Tidy(object):
    def __init__(self, app, **tidy_config):
        self.app = app
        self.tidy_config = tidy_config

    def __call__(self, environ, start_response):
        output = self.app(environ, start_response)
        output = "".join(output)
        output = tidy.parseString(output, **self.tidy_config)
        output = str(output)  # Assume 8-bit encoded string.
        return [output]

And the section in middleware.py (below the error handling);

    if asbool(full_stack) and asbool(global_conf.get("debug", False)):
        app = Tidy(app,       #validator(Tidy(validator(app),
            output_html=1, char_encoding="utf8", force_output=1)

(show_errors defaults to 6, the highest, and it doesn't help if I specify it.)

The browser just shows the normal page, although the <head> section
has a Tidy <meta> annotation.  But when it tries to load some images
(which don't exist) I get an error on the console:

127.0.0.1 - - [12/Apr/2007:14:26:06 -0700] "GET /images/map.jpg
HTTP/1.1" 404 - "http://localhost:5000/";
Error: app_iter.close() was not called when finishing WSGI request.
finalization function <function close_config at 0xb6e3aae4> not called

I assume that's because I'm not checking the Content-Type header.  So
I could go through the headers and do that, although it would be nicer
to do in my base controller with the Response object.  But since
uTidylib isn't doing the main thing I wanted it to do anyway, I
thought I'd ask first if it's worth it.

Using uTidylib 0.2 with libtidy 5.10.26, and ctypes 1.0.1 on Python
2.4.3 on Gentoo.

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to