Re: Form patches

"Jonathan Ellis" <[email protected]> Tue, 12 Sep 2006 14:29:44 -0700
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
On Tue, 12 Sep 2006 14:12:27 -0400, "Matt Schmidt" <[email protected]>
said:
> The image type requires a patch to spyceCompile.py because of the way
> the html image-submit works. It's just a one liner to strip out '.x'
> from the handlerid. It'd probably be better to splice the string, but
> I didn't feel like it.

I don't have time to look at the code right now but it seems cleaner to
do something like this instead:

// javascript
function parent_form(node) {
    while (true) {
        node = node.parentNode;
        if (!node || node.nodeName == 'BODY') {
            return null;
        }
        if (node.nodeName == 'FORM') {
            return node;
        }
    }
}

# python
return '<a href="#" onclick="parent_form(this).submit()"><img ...></a>'

(You could put the javascript in util/handlers.js to avoid spitting it
out inline.)

(Javascript is tested in FF and IE, you're welcome to have at it in
Opera or Safari but my guess is it will work fine there too.)

-Jonathan
-- 
C++ is history repeated as tragedy. Java is history repeated as farce.  --Scott McKay


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642