You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(This is copied from the mailing list. I enclose a patch, which includes a unit test.)
J.P's excellent article http://jcalderone.livejournal.com/50890.html
explains how to avoid calling Request.finish() on a request after its
connection was lost, because that now raises an exception. The code in
the article is able to avoid calling finish() because it handles the
rendering itself. The call to finish() is right there in _delayedRender.
But I'm using Nevow (because it's awesome) and all that stuff is done
behind the scenes, where I can't get to it.
My application has a form, which uses the Post/Redirect/Get pattern
(http://en.wikipedia.org/wiki/Post/Redirect/Get) to avoid
double-posting. Because processing is not instant, the browser receives
the HTTP header telling it to redirect before the processing has
finished. When the processing finishes, the Deferred embedded in the web
page fires with a value, Stan finishes flattening the page, and Nevow
calls Request.finish(). By then the browser has closed the connection
and sent in the GET request. So I get an error every single time.
Any page that uses Deferreds and redirects will do as well.
This is a completely self-contained example, to be run with twistd:
from nevow import tags, inevow, loaders, appserver
from nevow.rend import Page
from nevow.url import URL
from twisted.internet.task import deferLater
from twisted.internet import reactor
from twisted.application import service
from twisted.application.internet import TCPServer
from twisted.web import http
(This is copied from the mailing list. I enclose a patch, which includes a unit test.)
J.P's excellent article http://jcalderone.livejournal.com/50890.html
explains how to avoid calling Request.finish() on a request after its
connection was lost, because that now raises an exception. The code in
the article is able to avoid calling finish() because it handles the
rendering itself. The call to finish() is right there in _delayedRender.
But I'm using Nevow (because it's awesome) and all that stuff is done
behind the scenes, where I can't get to it.
My application has a form, which uses the Post/Redirect/Get pattern
(http://en.wikipedia.org/wiki/Post/Redirect/Get) to avoid
double-posting. Because processing is not instant, the browser receives
the HTTP header telling it to redirect before the processing has
finished. When the processing finishes, the Deferred embedded in the web
page fires with a value, Stan finishes flattening the page, and Nevow
calls Request.finish(). By then the browser has closed the connection
and sent in the GET request. So I get an error every single time.
Any page that uses Deferreds and redirects will do as well.
This is a completely self-contained example, to be run with twistd:
from nevow import tags, inevow, loaders, appserver
from nevow.rend import Page
from nevow.url import URL
from twisted.internet.task import deferLater
from twisted.internet import reactor
from twisted.application import service
from twisted.application.internet import TCPServer
from twisted.web import http
class Redirector(Page):
application = service.Application('Demo')
site = appserver.NevowSite(Redirector())
webservice = TCPServer(8123, site)
webservice.setName('WUI')
webservice.setServiceParent(application)
Imported from Launchpad using lp2gh.
The text was updated successfully, but these errors were encountered: