Python as network protocol

Diez B. Roggisch deets at nospam.web.de
Tue Nov 10 18:22:32 CET 2009


Daniel Fetchinson schrieb:
>>> I want to implement such specific feature:
>>> I have a server written in Python. I have a client written in C++. I
>>> want to use Python as network protocol between them. I mean: client
>>> send to server such string: "a = MyObject()", so object of this type
>>> will appear in server. Any ideas how to simplify this implementation?
>>> I make XML-RPC/SOAP server using twisted which just execute sended
>>> string. But I don't know how to:
>>> 1. Restrict usage of some modules on client side (os, sys etc..)
>>> 2. Divide variables of different clients. Generally, I know that I
>>> should use "exec .. in .. " construct, but don't know how to
>>> distinguish between clients in twisted.
> 
> Have you considered using pyro?
> 
> http://pyro.sourceforge.net/

Have you considered that C++ doesn't support Pyro?


> 
>> This is a *really* bad idea.
> 
> How do you know for sure? Maybe the OP wants to use this thing with 3
> known researchers working on a cluster that is not even visible to the
> outside world. In such a setup the model the OP suggested is a
> perfectly reasonable one. I say this because I often work in such an
> environment and security is never an issue for us. And I find it
> always amusing that whenever I outline our code to a non-scientist
> programmer they always run away in shock and never talk to us again :)
> Nevertheless our code works perfectly for our purposes.

If you read the OP message, he himself stated that he wants to lock down 
the interpreter. Which isn't possible. So (scientific) reasoning can 
tell us that his application might not run in a happy-go-lucky 
environment of scientific research.

Additionally, there is always the option of mistakes being made 
involuntarily, so desigining a system that encourages these is a bad idea.

And last but not least, instead of having a well-defined protocol 
relying on arbitrary in-process manipulation is a nightmare to maintain, 
and might well lead to nasty bugs, crashes or even subtler problems 
(think changing a global constant for all the others...) that are nearly 
impossible to debug.

Plus the issues the others mentioned.

Diez



More information about the Python-list mailing list