[Zope3-checkins] SVN: Zope3/trunk/ Attempt resolving issue
http://www.zope.org/Collectors/Zope3-dev/655 by removing abort() calls
from
zope.app.form and modifying the publication object to not attempt a
commit of doomed transactions.
Christian Theune
ct at gocept.com
Fri Mar 9 15:59:43 EST 2007
Hi,
thanks for starting to use txn.doom()!
However, I think this change in zope.app.publication needs a bit more
testing than the one test in zope.app.form.browser.
Christian
Am Sonntag, den 04.03.2007, 17:19 -0500 schrieb Brian Sutherland:
> Log message for revision 72976:
> Attempt resolving issue http://www.zope.org/Collectors/Zope3-dev/655 by removing abort() calls from zope.app.form and modifying the publication object to not attempt a commit of doomed transactions.
>
> Changed:
> U Zope3/trunk/doc/CHANGES.txt
> U Zope3/trunk/src/zope/app/form/browser/editview.py
> U Zope3/trunk/src/zope/app/form/browser/formview.py
> U Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
> U Zope3/trunk/src/zope/app/publication/zopepublication.py
>
> -=-
> Modified: Zope3/trunk/doc/CHANGES.txt
> ===================================================================
> --- Zope3/trunk/doc/CHANGES.txt 2007-03-04 21:03:50 UTC (rev 72975)
> +++ Zope3/trunk/doc/CHANGES.txt 2007-03-04 22:19:14 UTC (rev 72976)
> @@ -102,6 +102,10 @@
> session data for anonymous requests. This reduces zodb
> conflicts for high-traffic sites with many anonymous requests.
>
> + - Change the publication object to abort the current transaction if
> + the trasaction was doomed. Related to:
> + http://www.zope.org/Collectors/Zope3-dev/655.
> +
> Restructuring
>
> - Moved IBroken to zope.app.broken.interfaces to avoid cyclic imports.
> @@ -355,10 +359,13 @@
> - Added ObjectModifiedEvent when a text file object is modified through
> the edit form in the ZMI.
>
> + - Resolved http://www.zope.org/Collectors/Zope3-dev/655 by having
> + zope.app.form use the transaction.doom() interface.
> +
> Much thanks to everyone who contributed to this release:
>
> Jim Fulton, Dmitry Vasiliev, Martijn Faassen, Christian Theune, Wolfgang
> - Schnerring, Fred Drake, Marius Gedminas, Baiju M
> + Schnerring, Fred Drake, Marius Gedminas, Baiju M, Brian Sutherland
>
> ------------------------------------------------------------------
>
>
> Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
> ===================================================================
> --- Zope3/trunk/src/zope/app/form/browser/editview.py 2007-03-04 21:03:50 UTC (rev 72975)
> +++ Zope3/trunk/src/zope/app/form/browser/editview.py 2007-03-04 22:19:14 UTC (rev 72976)
> @@ -102,7 +102,7 @@
> except WidgetsError, errors:
> self.errors = errors
> status = _("An error occurred.")
> - transaction.abort()
> + transaction.doom()
> else:
> setUpEditWidgets(self, self.schema, source=self.adapted,
> ignoreStickyValues=True,
>
> Modified: Zope3/trunk/src/zope/app/form/browser/formview.py
> ===================================================================
> --- Zope3/trunk/src/zope/app/form/browser/formview.py 2007-03-04 21:03:50 UTC (rev 72975)
> +++ Zope3/trunk/src/zope/app/form/browser/formview.py 2007-03-04 22:19:14 UTC (rev 72976)
> @@ -13,7 +13,7 @@
> ##############################################################################
> """Form View Classes
>
> -$Id: editview.py 29143 2005-02-14 22:43:16Z srichter $
> +$Id$
> """
> __docformat__ = 'restructuredtext'
>
> @@ -76,7 +76,7 @@
> except WidgetsError, errors:
> self.errors = errors
> status = _("An error occurred.")
> - transaction.abort()
> + transaction.doom()
> else:
> if changed:
> status = self.setData(self.data)
>
> Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
> ===================================================================
> --- Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2007-03-04 21:03:50 UTC (rev 72975)
> +++ Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2007-03-04 22:19:14 UTC (rev 72976)
> @@ -24,6 +24,7 @@
> from zope.schema import TextLine
> from zope.traversing.api import traverse
>
> +from zope.app.form.browser.editview import EditView
> from zope.app.form.testing import AppFormLayer
> from zope.app.form.browser.ftests.support import *
> from zope.app.testing.functional import BrowserTestCase
> @@ -46,7 +47,7 @@
>
> def test_rollback_on_error(self):
> """Tests rollback when a widget error occurs.
> -
> +
> When one or more errors are generated by input widgets, the current
> transaction should be rolledback to ensure object integrity.
> """
> @@ -55,13 +56,25 @@
> self.getRootFolder()['foo'].optional_text = u'initial optional'
> transaction.commit()
>
> - # submit form with legal value for optional_text and invalid for
> + # submit form with legal value for optional_text and invalid for
> # required_text
> - response = self.publish('/foo/edit.html', form={
> - 'field.optional_text': u'',
> - 'field.required_text': u'',
> - 'UPDATE_SUBMIT': ''})
> - self.assertEqual(response.getStatus(), 200)
> + old_update = EditView.update
> + try:
> + def new_update(self):
> + # This update changes something after form validation has failed.
> + # Side effects like this should not be committed.
> + # http://www.zope.org/Collectors/Zope3-dev/655
> + result = old_update(self)
> + self.context.required_text = u'changed after form validation'
> + return result
> + EditView.update = new_update
> + response = self.publish('/foo/edit.html', form={
> + 'field.optional_text': u'',
> + 'field.required_text': u'',
> + 'UPDATE_SUBMIT': ''})
> + self.assertEqual(response.getStatus(), 200)
> + finally:
> + EditView.update = old_update
>
> # confirm that one errors exists
> self.assert_(patternExists(
>
> Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
> ===================================================================
> --- Zope3/trunk/src/zope/app/publication/zopepublication.py 2007-03-04 21:03:50 UTC (rev 72975)
> +++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2007-03-04 22:19:14 UTC (rev 72976)
> @@ -162,10 +162,12 @@
>
> def afterCall(self, request, ob):
> txn = transaction.get()
> - self.annotateTransaction(txn, request, ob)
> + if txn.isDoomed():
> + txn.abort()
> + else:
> + self.annotateTransaction(txn, request, ob)
> + txn.commit()
>
> - txn.commit()
> -
> def endRequest(self, request, ob):
> endInteraction()
> notify(EndRequestEvent(ob, request))
>
> _______________________________________________
> Zope3-Checkins mailing list
> Zope3-Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-checkins
--
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/zope3-checkins/attachments/20070309/97f9fe83/attachment.bin
More information about the Zope3-Checkins
mailing list