SimpleXMLRPCServer and creating a new object on for each new client request.
google at smetj.net
google at smetj.net
Sat May 9 15:02:14 EDT 2009
On May 8, 1:17 am, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> Jelle Smet <je... at smetj.net> (JS) wrote:
>
> One more thing:
>
> >JS> I start python interactively:
> >>>>> import xmlrpclib
> >>>>> session1=xmlrpclib.ServerProxy('http://localhost:8000')
> >>>>> session2=xmlrpclib.ServerProxy('http://localhost:8000')
> >>>>> print session1.show_random()
> >JS> 13930
> >>>>> print session2.show_random()
> >JS> 13930
>
> I get the impression, also from your use of the variable names
> 'session1' and 'session2' that xmlrpclib.ServerProxy() gives you some
> kind of connection to the XMLRPC server. This is not the case. It gives
> just an administration object *in the client* that will communicate with
> the server when you call a method on it. The two session's in your code
> are therefore functionally equivalent and there is no advantage in
> having two of them instead of one. And the name session is misleading.
>
> Please note also that XMLRPC isn't object-oriented. There is just the
> server; in the protocol there are no objects other than the server.
> --
> Piet van Oostrum <p... at cs.uu.nl>
> URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
> Private email: p... at vanoostrum.org
Hi Piet,
Yes, I'm aware of this.
>You create a single instance of your class and then register that. There
>is nothing in your code that makes the server believe it should create a
>new instance for each request.
>On the other hand, If SimpleXMLRPCServer had this capability, my example wouldn't be correct anyway, because only one instance of class Randomizer is >created when the SimpleXMLRPCServer starts.
Exactly, I understand.
>Otherwise you would have to register a function that creates a new
>instance on every call.
>But as Martin P. Hellwig has noted, it wouldn't give you sessions anyway.
Well, I think Martin's example will suit my needs.
Thanks for the explanation!
Jelle
Thanks for the feedback, ...
More information about the Python-list
mailing list