[zope2-tracker] [Bug 787541] Re: WSGIPublisher leaves the request open on error
Brian Sutherland
jinty at web.de
Mon Oct 17 03:56:29 UTC 2011
On Sun, Oct 16, 2011 at 02:51:16PM -0000, stephan_hofmockel wrote:
> Hello,
> the current implementation of this bugfix breaks the following code.
> Assuming a request which sends 'a' and 'b' as parameters, eg. URL?a=test&b=test
>
> import transaction
>
> def do_something(self, request):
> self.attribute_a = request.get('a')
> transaction.commit()
> ...... possible other code which raises an Exception .....
> # the b parameter has to occur !
> assert request.get('b') == None
There are also other situations where this code probably will not work
as expected. For example, on serialization errors Zope can retry a
request, a few times.
If you get serialization errors after commit(), it may be that the
request is retried and you get a second or third commit() where you only
wanted one.
As a bonus, serialization errors most often happen on a loaded site.
> I use this in situations where I would like to be sure that 'self.attrbiute_a' is inside the ZODB regardless if an error happens afterwards or not. However after transaction.commit() the request is closed, because transaction.commit() calls 'afterCompletion' of '_RequestCloserForTransaction'. This means all parameters send in a form are lost/cleared and not available anymore.
>
> Would it make sens to change the Bugfix in ZPublisher a little bit so that
> 247 _request_closer_for_repoze_tm.add(txn, request)
> is called after
> 252 response = _publish(request, 'Zope2')
It may help.
> If its a bug in ZOPE, I can work on a patch + test.
> If I'm misusing transaction.commit(), plz tell me how it is done right.
I'm reasonably certain that you almost never want to call commit()
during a transaction. I've never used it, but perhaps savepoint() fits
your usecase better.
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/787541
>
> Title:
> WSGIPublisher leaves the request open on error
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zope2/+bug/787541/+subscriptions
--
Brian Sutherland
--
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.
https://bugs.launchpad.net/bugs/787541
Title:
WSGIPublisher leaves the request open on error
To manage notifications about this bug go to:
https://bugs.launchpad.net/zope2/+bug/787541/+subscriptions
More information about the zope2-tracker
mailing list