Re: zope.formlib's action decorator return Action() object, not the decorated function. Why?
Marius Gedminas <[email protected]>
| Newsgroups | gmane.comp.web.zope.devel |
|---|---|
| Message-ID | <20120916052802.GA10743@platonas> |
On Fri, Sep 14, 2012 at 01:44:30PM +0200, Jan-Wijbrand Kolman wrote: > After years and years of heavily using zope.formlib it suddenly struck > me that the zope.formlib.form.action decorator returns an Action() > object instead of the decorated function (this action object is also > added to the form's actions sequence as a "side effect" of the decorator). > > I know wonder: Why? (I've no clue.) > I cannot find a use case for wanting the action object added to the > class members under the name of the decorated function. But maybe there is? > > The reason I came across this "issue" is trying to improve the test > coverage of the application I'm building somewhat closer to 100% and > found that the form actions implementation *appeared* not to be covered > at all - even if there clearly are tests for these. How are you measuring coverage? How are you testing the handlers? I'm asking because I haven't encountered this issue in my projects -- form action handlers show up in my test coverage just fine. > I tried having the decorator "just" returning the function, and at least > all zope.formlib's tests themselves do pass. > > Would anyone mind if I would change the behaviour of the decorator? I have unit tests that invoke view.handle_foo_button.handler() directly, because they assume zope.formlib's @action replaces the handle_foo_button method with an Action. Your change would break my tests, but they would be trivial to fix, so my vote would be -0, with the request of a larger version bump to indicate backwards-incompatibility. Marius Gedminas -- http://pov.lt/ -- Zope 3/BlueBream consulting and development _______________________________________________ Zope-Dev maillist - [email protected] https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
signature.asc
(application/pgp-signature, 190 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iD8DBQFQVWNikVdEXeem148RArjaAJ99iUGSU8suo2AocsKH1xFRU4NbLwCZAbdr Nnl45lks3kbaQfOMUprj+Jg= =aqrr -----END PGP SIGNATURE-----