0

Is there a Python extension that would allow me to import remote functions and objects with the same syntax that I import now from files? I'm thinking of something like:

from com.coolmaps.drawing.v21 import draw_map

Then when later in my code i call draw_map, that automatically would be translated to mean a remote method call on that given server.

Wouldn't that be cool?

mircealungu
  • 6,831
  • 7
  • 34
  • 44

1 Answers1

1

Check modules from that question for remote method call: What is the current choice for doing RPC in python?

Here is example from SOAPpy:

A simple “Hello World” http SOAP server:

import SOAPpy
def hello():
    return "Hello World"
server = SOAPpy.SOAPServer(("localhost", 8080))
server.registerFunction(hello)
server.serve_forever()

And the corresponding client:

import SOAPpy
server = SOAPpy.SOAPProxy("http://localhost:8080/")
print server.hello()

But I don't know if any of them allow to do it with import/from syntax.

graphite
  • 2,920
  • 22
  • 40
  • Thanks for the answer! I guess my question was more about whether we can import external services with the same import statement that we do now local modules. But then again, it would save two lines of code... so maybe not worth it :) – mircealungu Feb 12 '16 at 08:37
  • IMHO it doesn't look good to code url in module name. But I think it is possible with importlib. – graphite Feb 12 '16 at 08:52