Going from webscripting to server-client software.

Stephen shriek at gmx.co.uk
Sun Jul 29 22:26:47 EDT 2001


Thank you for demystifying this for me Duncan. Have since been searching
the web for layman's (or at least novice programmer) guides to CORBA and
just in case anybody else finds themselves having to follow the same steps,
one of the best I've found is
http://developer.java.sun.com/developer/onlineTraining/corba/
don't worry about it being written for Java, it's the most simplified
I've found, assuming no prior knowledge of CORBA and accompanying jargon.

Now, in order to test your example, I've downloaded OmniOrbpy and am 
about to install OmniOrb 3.x, as described at 
http://www.uk.research.att.com/omniORB/omniORB_3/README_win32.html
It specifies that the pre-built binaries work for winNT/98 and uses 
Python 1.52. Will try with win2000 and Python 2.1 but was wondering
if you know of any changes/differences ? 

Thank you again for the example you provided,

Stephen.



> In article <97ae44ee.0107262210.795d3e0e at posting.google.com>,
>  Stephen <shriek at gmx.co.uk> wrote:
> 
> [...]
> >Thank you very much, Duncan.  After looking around for a couple of days (hence
> >my late followup. sorry), it does seem like my options are 
> >(a) CORBA
> >(b) SOAP
> >(c) XMLRPC
> >(d) Pyro
> 
> You might want to add DOPY, which is along the same lines as Pyro:
> 
>   http://www.users.cloud9.net/~proteus/dopy/welcome.html
> 
> I don't know anything about it, though.
> 
> >CORBA has always been intimidating. So much work just to do "hello world",
> >let along build a full app.
> 
> People often say this, but it just isn't true, especially if you use
> Python. "Hello world" doesn't make a lot of sense in a distributed
> application, but here's the full code for a "fortune cookie" service.
> 
> First, declare the interface in IDL:
> 
>   // fortune.idl
>   module Fortune {
>     interface CookieServer {
>       string get_cookie();
>     };
>   };
> 
> Now convert it to Python declarations with your chosen ORB's IDL
> compiler, for example with omniORBpy:
> 
>   $ omniidl -bpython fortune.idl
> 
> [ orbit-python doesn't have the IDL compiler step -- it always
>   compiles it on the fly. ]
> 
> First the client, on the Python command line:
> 
>   >>> import CORBA, Fortune
>   >>> orb = CORBA.ORB_init()
>   >>> o = orb.string_to_object("corbaloc::spud.uk.research.att.com/fortune")
>   >>> o = o._narrow(Fortune.CookieServer)
>   >>>
>   >>> print o.get_cookie()
>   Objects are lost only because people look where they are not rather than
>   where they are.
> 
>   >>> print o.get_cookie()
>   "I'd love to go out with you, but I'm staying home to work on my
>   cottage cheese sculpture."
> 
> 
> There really is a fortune cookie server running on
> spud.uk.research.att.com, so you can run this example.
> 
> 
> Now the server:
> 
>   #!/usr/bin/env python
>   
>   import sys, os
>   import CORBA, Fortune, Fortune__POA
>   
>   FORTUNE_PATH = "/usr/games/fortune"
>   
>   class CookieServer_i (Fortune__POA.CookieServer):
>       def get_cookie(self):
> 	  pipe   = os.popen(FORTUNE_PATH)
> 	  cookie = pipe.read()
> 	  if pipe.close():
> 	      # An error occurred with the pipe
> 	      cookie = "Oh dear, couldn't get a fortune\n"
> 	  return cookie
>   
>   orb = CORBA.ORB_init(sys.argv)
>   poa = orb.resolve_initial_references("RootPOA")
>   
>   servant = CookieServer_i()
>   poa.activate_object(servant)
>   
>   print orb.object_to_string(servant._this())
>   
>   poa._get_the_POAManager().activate()
>   orb.run()
> 
> 
> That's it. Note that about half the lines of code are nothing to do
> with CORBA -- they're just getting the fortune cookie. When you run
> the server it prints a long hex string like:
> 
> IOR:010000001d00000049444c3a466f7274756e652f436f6f6b69655365727665723
> a312e300000000001000000000000005c000000010102000d0000003135382e313234
> 2e36342e330000f90a07000000666f7274756e6500020000000000000008000000010
> 0000000545441010000001c0000000100000001000100010000000100010509010100
> 0100000009010100
> 
> which can be given to orb.string_to_object (without the line breaks).
> That IOR string is also the server running on spud.uk.research.att.com.
> 
> A version of the server that can be used with the corbaloc URI is just
> as simple, but omniORB specific, so I haven't shown that.
> 
> Cheers,
> 
> Duncan.



More information about the Python-list mailing list