[omniORB] using class from omniidl compiler generated xyz_idl.py file

Duncan Grisby duncan at grisby.org
Fri May 1 09:51:33 UTC 2020


On Thu, 2020-04-30 at 21:06 +0100, Toyin Awofala via omniORB-list
wrote:

> I am writing a python corba client to a server app corba interface I
> generated a stub file YDS_idl.py y using omniidl compiler to compile
> idl provided by the server. I am able to get the serer IOR string
> representation with: 
> orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) 
> obj = orb.string_to_object(SERVER_IIOP_URL) 
>  
> I now import class from the stub to narrow into a server obj. 
> srv_obj = YDSAdminIF._narrow(obj) 
> 
> I keep getting error: 
>     from YDS_idl.py import YDSAdminIF ImportError: 
>     cannot import name YDSAdminIF

You are importing the wrong thing. You haven't told us what is in your
YDS.idl file, but it is definitely wrong to import YDS_idl, and you
never import Python code by including the .py extension in the import
statement.

If YDS.idl contains a top-level module declaration like this:

  module YDSModule {
    interface YDSAdminIF {...};
  };

then in Python you need to import YDSModule:

  from YDSModule import YDSAdminIF


If, on the other hand, the IDL file does not contain a top-level
module, like this:

  interface YDSAdminIF {...};

then the Python CORBA mapping says it is in a pretend module called
"_GlobalIDL", so you need to import that:

  from _GlobalIDL import YDSAdminIF


Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --





More information about the omniORB-list mailing list