[Twisted-Python] xmlrpc protocoll instanze per connection?
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Thu Aug 5 09:01:23 MDT 2010
On 02:21 pm, petshmidt at googlemail.com wrote:
>On Thu, Aug 5, 2010 at 3:32 PM, Alan Franzoni <mailing at franzoni.eu>
>wrote:
>>On 8/4/10 1:30 PM, Pet wrote:
>>>AFAIU this works only if Factory is subclassing
>>>protocol.ServerFactory, XMLRPCFactory subclasses server.Site, where
>>>protocol attribute is not present
>>
>>server.Site subclasses http.HTTPFactory which, in turns, subclasses
>>protocol.ServerFactory:
>>
>>http://twistedmatrix.com/documents/10.0.0/api/twisted.web.server.Site.html
>>
>>
>>by the way, if I now understand your question: just subclass XMLRPC
>>and
>>create your own xmlrpc resource class by adding methods like
>>
>>xmlrpc_somemethod
>>xmlrpc_othermethod
>>
>>then add such handler to your server.Site, and you're done. Your
>>method
>>will be invoked once per request.
>
>what I've tried to do is to have objects, which were members of
>XMLRPC. And these objects would have some internal state which is
>isolated per request. But each new request has changed this objects,
>because xmlrpc is created once and not for each request or connection.
>I've solved this by modifying render_POST where I create those objects
>before calling requested function and so they lives only there without
>being overwritten by new request. Ugh... It's might be ugly, but works
>for me
If you want a new XMLRPC instance per request, then create a new one per
request. http://twistedmatrix.com/documents/current/web/howto/web-in-60
/dynamic-dispatch.html may help.
Re-using a single XMLRPC instance and mangling its state in render_POST
will break as soon as your server receives two overlapping requests.
Jean-Paul
More information about the Twisted-Python
mailing list