[twill] tidy_ok is nice, but I need something more strict

Titus Brown titus at caltech.edu
Thu Dec 27 22:38:02 PST 2007

-> I went in a slightly different direction.  What I was really after was a
-> way to enforce some in-house standards on code.  I wrote this plugin in
-> about an hour.  I'm curious what people think about it.

->     def img_has_alt():
->         "Verify every img tag has an alt attribute."
->     def no_nested_tables():
->         "Verify no table has a table inside."
-> I was thrilled with how easy it was to write this twill plugin.  I'd
-> like to make this play nice with require.

Hey Matt,

interesting stuff!  Seems generally useful; comments from anyone else?

(I like the name, too ;)

Playing nice with 'require', specifically, may be difficult; it would
require patching the 'require' extension module.  But see these lines
from twill/extensions/require.py:

    if _require_post_load_hook not in commands.browser._post_load_hooks:
       if DEBUG:
          print>>commands.OUT, 'INSTALLING POST-LOAD HOOK'

'require' works by installing a 'post load hook' function that is run
every time a new page is loaded.  You can certainly make use of that
functionality directly from your extension module.


More information about the twill mailing list