Discussion:
[omniORB] How to cdrMarshal CORBA.Any value?
Anton Dedov
2007-12-28 15:27:19 UTC
Permalink
Hi!
s = SecurityContext(...)
s_any = CORBA.Any(CORBA.TypeCode(CORBA.id(s)), s)
cdrMarshal(CORBA.TypeCode(CORBA.id(s_any)), s_any)
Traceback (most recent call last):
File "<console>", line 1, in ?
File "./omniORB/CORBA.py", line 480, in id
BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)

Can anyone advise me how I can generate TypeCode for CORBA::Any. Or maybe I am trying to do something fundamentally wrong?

--
Anton Dedov
Software Developer, PEM
SWsoft

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071228/21abb52a/attachment.htm
Anton Dedov
2007-12-29 13:58:25 UTC
Permalink
Closed - I found decision my-self:

class MyAny:
_NP_RepositoryId = "IDL:omg.org/CORBA/Any:1.0"
def __init__(self, *args, **kw):
raise RuntimeError("Cannot construct objects of this type.")

_d_MyAny = (omniORB.tcInternal.tv_any, omniORB.tcInternal.tv_any, 0)
_ad_MyAny = (omniORB.tcInternal.tv_alias, MyAny._NP_RepositoryId, "Any", (omniORB.tcInternal.tv_any, omniORB.tcInternal.tv_any, 0))
_tc_MyAny = omniORB.tcInternal.createTypeCode(_ad_MyAny)
omniORB.registerType(MyAny._NP_RepositoryId, _ad_MyAny, _tc_MyAny)
del MyAny

def insertCreds(name, ctx, exc = None):
...
s = SecurityContext(...)
sany = CORBA.Any(CORBA.TypeCode(CORBA.id(s)), s)
smr = cdrMarshal(_tc_MyAny, sany)
ctx.append( (sid, smr) )

--
Anton Dedov
Software Developer, PEM
SWsoft

From: omniorb-list-***@omniorb-support.com [mailto:omniorb-list-***@omniorb-support.com] On Behalf Of Anton Dedov
Sent: Friday, December 28, 2007 3:27 PM
To: omniorb-***@omniorb-support.com
Subject: [omniORB] How to cdrMarshal CORBA.Any value?

Hi!
s = SecurityContext(...)
s_any = CORBA.Any(CORBA.TypeCode(CORBA.id(s)), s)
cdrMarshal(CORBA.TypeCode(CORBA.id(s_any)), s_any)
Traceback (most recent call last):
File "<console>", line 1, in ?
File "./omniORB/CORBA.py", line 480, in id
BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)

Can anyone advise me how I can generate TypeCode for CORBA::Any. Or maybe I am trying to do something fundamentally wrong?

--
Anton Dedov
Software Developer, PEM
SWsoft

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071229/fbb0a986/attachment.htm
Stephen Hansen
2007-12-29 15:52:15 UTC
Permalink
Hmm?
from omniORB import any
s_any = any.to_any(s)

Won't that work?
-_Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20071229/169b77b7/attachment.htm
Duncan Grisby
2007-12-29 19:35:56 UTC
Permalink
I am trying form request context in interceptor via Python interface
of omniORB. Our server part is working under ACE-TAO. Server-side
interceptors wait for a context data encapsulated into Any. But I
s = SecurityContext(...)
s_any = CORBA.Any(CORBA.TypeCode(CORBA.id(s)), s)
cdrMarshal(CORBA.TypeCode(CORBA.id(s_any)), s_any)
File "<console>", line 1, in ?
File "./omniORB/CORBA.py", line 480, in id
BAD_PARAM: CORBA.BAD_PARAM(omniORB.BAD_PARAM_WrongPythonType, CORBA.COMPLETED_NO)
CORBA.id() is only intended to work on declared types, not on base types
like Any. According to the mapping specification, you should use
CORBA.TC_any to get Any's TypeCode:

cdrMarshal(CORBA.TC_any, s_any)

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...