Discussion:
[omniORB] omniORBpy-3.0 "casting" inout Parameters
aaaa bbbb
2007-08-17 15:55:56 UTC
Permalink
I have to use the following interface:

module A
{
[...]
struct Attr {
string name;
SomeType type;
long numericv;
string textv;
SomeType2 state;
};

typedef sequence<Attr> AttrSeq;

}

module B
{
[...]

A::RetType myFkt(
in A::Type1 ver, // Enumeration
inout A::Type2 obj,
inout A::AttrSeq theList)
raises (A::SomeException);

}

import A
import B

[...]
ret, obj, theList=obj.myFkt(A.NUMBER1, obj, theList)

will throw an BAD_PARAM_WrongPythonType exception. How
can I "cast" obj and theList to the correct type?
I have read the OMG "Python Language Mapping
Specification" but was not able to find any
information. Thanks for any help!





____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
Duncan Grisby
2007-08-18 00:08:05 UTC
Permalink
Post by aaaa bbbb
module A
{
[...]
struct Attr {
string name;
SomeType type;
long numericv;
string textv;
SomeType2 state;
};
typedef sequence<Attr> AttrSeq;
}
module B
{
[...]
A::RetType myFkt(
in A::Type1 ver, // Enumeration
inout A::Type2 obj,
inout A::AttrSeq theList)
raises (A::SomeException);
}
import A
import B
[...]
ret, obj, theList=obj.myFkt(A.NUMBER1, obj, theList)
will throw an BAD_PARAM_WrongPythonType exception. How
can I "cast" obj and theList to the correct type?
I have read the OMG "Python Language Mapping
Specification" but was not able to find any
information. Thanks for any help!
You've missed out the important bit of the code where you populate the
argument values. You are calling the operation with the right number of
arguments, and extracting the right return values. The problem is that
the arguments don't have the right types according to the IDL. It's
nothing to do with the fact that they are declared inout.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
aaaa bbbb
2007-08-19 22:38:08 UTC
Permalink
Post by aaaa bbbb
Post by aaaa bbbb
module A
{
[...]
struct Attr {
string name;
SomeType type;
long numericv;
string textv;
SomeType2 state;
};
typedef sequence<Attr> AttrSeq;
}
module B
{
[...]
A::RetType myFkt(
in A::Type1 ver, // Enumeration
inout A::Type2 obj,
inout A::AttrSeq theList)
raises (A::SomeException);
}
import A
import B
[...]
ret, obj, theList=obj.myFkt(A.NUMBER1, obj,
theList)
Post by aaaa bbbb
will throw an BAD_PARAM_WrongPythonType exception.
How
Post by aaaa bbbb
can I "cast" obj and theList to the correct type?
I have read the OMG "Python Language Mapping
Specification" but was not able to find any
information. Thanks for any help!
You've missed out the important bit of the code
where you populate the
argument values. You are calling the operation with
the right number of
arguments, and extracting the right return values.
The problem is that
the arguments don't have the right types according
to the IDL. It's
nothing to do with the fact that they are declared
inout.
Thanks for your reply!

That is exactly the problem. I don't know how to
create variables with the correct type.

theList = A.AttrSeq()
will fail with an exception (__init__ method of
A.AttrSeq create by omniiorb is " raise
RuntimeError("Cannot construct objects of this
type.")")



____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz



____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
Luke Deller
2007-08-20 06:22:23 UTC
Permalink
...
Post by aaaa bbbb
Post by aaaa bbbb
struct Attr {
string name;
SomeType type;
long numericv;
string textv;
SomeType2 state;
};
typedef sequence<Attr> AttrSeq;
...
Post by aaaa bbbb
That is exactly the problem. I don't know how to
create variables with the correct type.
theList = A.AttrSeq()
will fail with an exception (__init__ method of
A.AttrSeq create by omniiorb is " raise
RuntimeError("Cannot construct objects of this
type.")")
Yes, CORBA sequences are mapped to Python lists (as per section 1.3.2 of the "Python Language Mapping Specification"), so you don't want to create AttrSeq instances.

CORBA structs are mapped to Python instances, so you will want to create A.Attr instances and put these into your list.

eg:
theList = [
A.Attr(name='foo',type=someVal,numericv=42,textv='foo',state=someVal2),
A.Attr(name='bar',type=someVal,numericv=42,textv='bar',state=someVal2),
]

Regards,
Luke.
**********************************************************************************************
Important Note
This email (including any attachments) contains information which is confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, distribute or copy this email. If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this email are not necessarily the views of IRESS Market Technology Limited.

It is the duty of the recipient to virus scan and otherwise test the information provided before loading onto any computer system.
IRESS Market Technology Limited does not warrant that the information is free of a virus or any other defect or error.
**********************************************************************************************
aaaa bbbb
2007-08-20 12:26:16 UTC
Permalink
Post by Luke Deller
....
Post by aaaa bbbb
Post by aaaa bbbb
struct Attr {
string name;
SomeType type;
long numericv;
string textv;
SomeType2 state;
};
typedef sequence<Attr> AttrSeq;
...
Post by aaaa bbbb
That is exactly the problem. I don't know how to
create variables with the correct type.
theList = A.AttrSeq()
will fail with an exception (__init__ method of
A.AttrSeq create by omniiorb is " raise
RuntimeError("Cannot construct objects of this
type.")")
Yes, CORBA sequences are mapped to Python lists (as
per section 1.3.2 of the "Python Language Mapping
Specification"), so you don't want to create AttrSeq
instances.
CORBA structs are mapped to Python instances, so you
will want to create A.Attr instances and put these
into your list.
theList = [
A.Attr(name='foo',type=someVal,numericv=42,textv='foo',state=someVal2),
A.Attr(name='bar',type=someVal,numericv=42,textv='bar',state=someVal2),
Post by Luke Deller
]
Excellent! That solved the problem. Thanks a lot!


____________________________________________________________________________________
Shape Yahoo! in your own image. Join our Network Research Panel today! http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
Loading...