[omniORB] CORBA.TypeCode() on enum fails in omniorbpy

Duncan Grisby duncan at grisby.org
Wed Jun 6 19:54:55 BST 2007


On Tuesday 5 June, Andrew Edem wrote:

> It does not seem possible to use CORBA.TypeCode() on enum definitions
> from stubs. I think this is because the python type of the enum
> definition is an instance while omniORB expects it to be a class.
> 
> I'm not entirely sure if this is a bug or by design, and I have no idea
> where the "right" place to fix it would be.

It's kind-of by design. The Python language mapping says:

  For user-defined types, a function CORBA.TypeCode can be used to
  create the type codes. This function expects the repository ID. If
  creation of the type code fails, CORBA.TypeCode raises a system
  exception. The repository ID of a type can be obtained with the
  function CORBA.id, passing the object representing the type. Such an
  object shall be available for every IDL type with a <scoped_name>,
  including names that are not otherwise mapped to a Python construct
  (such as type aliases). If an invalid object is passed to CORBA.id, a
  BAD_PARAM system exception is raised.

so you can get the TypeCode for your enum with:

  tc = CORBA.TypeCode(CORBA.id(Test.TestEnum))

It's an omniORB extension that you can use CORBA.TypeCode() directly
with other generated classes like those for structs and interfaces. I'll
make it work for enums too.

Another omniORB extension is that the IDL compiler helpfully makes a
TypeCode for you, so you can get the TypeCode you want just like this:

  tc = Test._tc_TestEnum

Cheers,

Duncan.

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



More information about the omniORB-list mailing list