[Twisted-web] Accessing request object from a SOAPPublisher soap_ method

Donovan Preston dp at ulaluma.com
Tue Jul 12 02:38:20 MDT 2005


On Jul 7, 2005, at 10:26 AM, Jonathan Blocksom wrote:

> Hi, I've got a SOAPPublisher class with some published methods and  
> I was hoping to access the HTTP request object from within.   
> Anybody know how to do this?

Unfortunately it doesn't look like it. If you look at the  
SOAPPublisher.render method, it looks up the callable and then calls  
it (indirecting through maybeDeferred). The only place the request is  
available is in the local namespace of render. So, you could:

1) override render, stuff the request somewhere (like self), then get  
it out in your method; you should only do this if threads are in no  
way involved. If there aren't any threads then it would be safe. Just  
be sure to get it out immediately and pass around what you got out  
(for example, don't return a deferred then look in self in a callback)

2) use some horrible callframe hack to extract the request from the  
caller's frame. This would have the advantage of being threadsafe,  
but you aren't using threads anyway -- right?

Itamar is the guy to talk to about SOAP and XMLRPC, but I guess he  
doesn't read this list. If you want to have a cleaner way of doing  
this in the future, you should probably talk to him about it, either  
on IRC or through email or something.

Donovan




More information about the Twisted-web mailing list