On 12:24 pm, peter.westlake(a)pobox.com wrote:
>On Wed, 13 Oct 2010 17:36 +0000, exarkun(a)twistedmatrix.com wrote:
>>On 05:22 pm, peter.westlake(a)pobox.com wrote:
>> >I'm about to start looking at this. Is there any formal procedure to
>> >or shall I just put in a ticket and assign it to myself?
>>That's the formal procedure. :)
>Okay, it's in as ticket 3031. I can't see a way to assign it to
>myself, probably because it wouldn't be sensible to give full
>access to random people off the Internet!
I gave you the "contributor" role which hopefully will let you do a few
more things with tickets.
I'm trying to add a single service to a virtual path like http://localhost:8080/geospatial/geocoder/XMLRPC.
The following code does not work:
root = resource.Resource()
srv = XMLRPCGeocoder()
When I attempt to access the service, twisted gives the following error:
Request failed: <ProtocolError for localhost:8080/geospatial/geocoder/XMLRPC: 404 Not Found>
If I use the following code, and change the client to point only to localhost:8080/XMLRPC, it _does_ work:
The docs say something about using putChild.putChild... so I tried the following:
root.putChild("geospatial", None).putChild("geocoder", None).putChild("XMLRPC", srv)
The problem is Resource.putChild _always_ returns None! Even the following, which is the working version:
print root.putChild("XMLRPC", srv) # Prints None too
Looking at twisted.web.resource.Resource's source code, all it does is add the path to a hash array and returns nothing...
It seems like such a simple thing to do! Thanks for your help!
Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.
On 05:22 pm, peter.westlake(a)pobox.com wrote:
>I'm about to start looking at this. Is there any formal procedure to
>or shall I just put in a ticket and assign it to myself?
That's the formal procedure. :)
>On Fri, 08 Oct 2010 17:50 +0100, "Peter Westlake"
>>On Fri, 08 Oct 2010 13:19 +0000, exarkun(a)twistedmatrix.com wrote:
>> > On 1 Oct, 02:31 pm, peter.westlake(a)pobox.com wrote:
>> > >J.P's excellent article
>> > >explains how to avoid calling Request.finish() on a request after
>> > >connection was lost, because that now raises an exception. The code
>> > >the article is able to avoid calling finish() because it handles
>> > >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
>> > >behind the scenes, where I can't get to it.
>> > Mmm. Indeed. Nevow doesn't make it easy to handle this case.
>> > Nevow itself should be taking some action in this case, I think.
>> > possibility would be to cancel the Deferred associated with the
>> > lookup/rendering operation. This would depend on having a new
>> > version of Twisted (such that Deferred cancellation is available)
>> > though. Otherwise all Nevow could really do is ignore the result of
>> > Deferred when it comes.
>>Is the version of Twisted with cancellation more recent than
>>the version of Nevow that detects the error? If not, it might
>>be reasonable to expect cancellation to be available. Or would
>>it be reasonable to test for it at the beginning of the Nevow source?
Unfortunately, the finish() error was introduced in Twisted 9.0 and
cancellation was introduced in 10.1. So there's a few combinations to
>> > Actually, ignoring the result might be a sensible thing to implement
>> > first anyway. It should be simpler and have no application
>> > except to get rid of the now-disallowed finish() call.
>> > Are you interested in helping implement this?
>>I'm certainly willing to try! Especially as I have a cron job
>>that mails me whenever it finds an exception in the log.
>>Any hints as to how to go about it would be very welcome.
>>So far I've found NevowRequest._cbFinishRender in appserver.py
>>- is that the right sort of area? And NevowSite.handleSegment?
That sounds like the right area.
I'm writing a client that is using t.w.client.downloadPage function to
download a large chunk of data into a file from a webserver. This is
Now I want use the same function (or at least take advantage of the
"save to file" functionality) and be able to send along with my request
a large chunk of data, without storing that chunk into memory.
To clarify my need here is an example
(1) client -> POST <large data file> -> server
(2) server computes
(3) server -> <REPLY with large data file> -> client
the (3) step is done in a memory efficient way using
t.w.c.downloadPage(). Right now I execute the (1) step using the
"postData" argument of t.w.c.downloadPage after loading all data into
Is there a way I can avoid loading all data into memory?
Thank you in advance,
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.
What is the correct method to tell Nevow to abandon the request, please?
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
count = 0
message = 0
self.count += 1
return deferLater(reactor, 3, self._increment)
def beforeRender(self, ctx):
req = inevow.IRequest(ctx)
if req.method == 'POST':
oldurl = URL.fromContext(ctx)
newurl = oldurl.remove('cmd')
self.message = self.slow_operation()
def render_message(self, ctx, data):
docFactory = loaders.stan(
tags.h1['Problem with interrupted connections'],
application = service.Application('Demo')
site = appserver.NevowSite(Redirector())
webservice = TCPServer(8123, site)
Thanks in advance,
Recently my nevow web server's unit tests started to fail, because the
tests used request.getHeader() to check that request.setHeader() had
been called correctly. This used to work.
I can see from testutil.py that setHeaders sets self.headers, but
getHeaders gets a value from received_headers, and there is a test in
test_testutil.py to make sure it does. So is this really how it is meant
to work? Is setHeader really meant to set something that getHeader can't
get? If so, what's the correct method for testing the result of
To reproduce the problem, run this with "trial":
from nevow.testutil import FakeRequest, TestCase
self.request = FakeRequest()