[omniORB] Return Struct o None

William Bauder bill at simplified.biz
Thu Mar 26 13:47:40 GMT 2009


CORBA doesn't allow nulls - try a discriminator union:

idl:
...
struct SInfo {
     wstring id;
     wstring address;
     wstring tlf;
}

union SInfoDiscriminator switch(boolean)
{
  case TRUE: SInfo value;
};

I don't know python, so this is pseudocode:

def get_personal_info(self, name):
     if name in self.personal_dict:
       return SInfoDiscrimitor().value(SInfo(self.personal_dict[name]['id'],
                       self.personal_dict[name]['address'],
                       self.personal_dict[name]['tlf']))
       else:
          return SInfoDiscrimitor()._default()

On the client side:
  sInfoDiscriminator=get_personal_info("...")
  if sInfoDiscriminator._d()==TRUE
    sInfo=sInfoDiscriminator.value()
  else
    sInfo=NULL



-----Original Message-----
From: omniorb-list-bounces at omniorb-support.com
[mailto:omniorb-list-bounces at omniorb-support.com] On Behalf Of Antonio
Beamud Montero
Sent: Thursday, March 26, 2009 1:11 PM
To: omniorb-list at omniorb-support.com
Subject: [omniORB] Return Struct o None


Hi all:
I've defined a struct, and a method that returns this struct type. The
problem is when I try to return a null value instead this struct. For
example:

idl:
...
struct SInfo {
     wstring id;
     wstring address;
     wstring tlf;
}

SInfo get_personal_info(in wstring name);

in python:
..
   def get_personal_info(self, name):
       if name in self.personal_dict:
          return SInfo(self.personal_dict[name]['id'],
                       self.personal_dict[name]['address'],
                       self.personal_dict[name]['tlf'])
       else:
          return None

If the name exists, all works well, but if not exists, the next error
appears:
omniORB.CORBA.BAD_PARAM: ORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType,
CORBA.COMPLETED_MAYBE)

I've tried with None, Corba.types.NoneType and CORBA.Object._nil
        , but the same error.

Thanks.


_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list




More information about the omniORB-list mailing list