Discussion:
[omniORB] omniORBpy Exception exceptions.AttributeError
Kyle Dunn
2009-04-28 04:37:10 UTC
Permalink
I am attempting to resolve two references to different CORBA C++ servants
using the following code:

def resolveCameraImplRef(self):
name = [CosNaming.NameComponent(BRAIN_NAME,""),
CosNaming.NameComponent(CAMERA_NAME,"")]
try:
cameraObj = self.manager.rootContextExt.resolve(name)
except:
printDebug( "Problem resolving Camera object name in
initCorbaOrb().cameraClientInit()" )
sys.exit(1)

client = cameraObj._narrow(gri._objref_Camera)
if client is None:
printDebug( "Problem narrowing cameraObj to a GRI::Camera in
initCorbaOrb().cameraClientInit()" )
sys.exit(1)
else:
return client

def resolvePanoramaImplRef(self):
name = [CosNaming.NameComponent(BRAIN_NAME,""),
CosNaming.NameComponent("Panorama","")]
try:
panoramaObj = self.manager.rootContextExt.resolve(name)
except:
printDebug( "Problem resolving Panorama object name in
initCorbaOrb().panoramaClientInit()" )
sys.exit(1)

panoramaClient = panoramaObj._narrow(gri._objref_Panorama)
if client is None:
printDebug( "Problem narrowing panoramaObj to a GRI::Panorama in
initCorbaOrb().panoramaClientInit()" )
sys.exit(1)
else:
return client

Before I added the clientImplRef code I was able to make calls to the C++
servant handling the panorama object. Now I can successfully resolve
references to the camera object but when the panorama is being reolved I
receive this:

Problem resolving Panorama object name in
initCorbaOrb().panoramaClientInit()
Exception exceptions.AttributeError: "_objref_Panorama instance has no
attribute '_Object__release'" in <bound method _objref_Panorama.__del__ of
<gri._objref_Panorama instance at 0xb79e3c6c>> ignored

If I need to provide more code please let me know. I don't know how to
decipher the error I'm receiving.

Cheers,

Kyle Dunn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20090427/ae8f5a2c/attachment.htm
Duncan Grisby
2009-04-28 22:18:38 UTC
Permalink
Post by Kyle Dunn
I am attempting to resolve two references to different CORBA C++ servants
[...]
Post by Kyle Dunn
client = cameraObj._narrow(gri._objref_Camera)
This is wrong. _objref_Camera is a private implementation detail of
omniORBpy. You should not refer to it.

The correct code is

client = cameraObj._narrow(gri.Camera)

Also, it's not generally a good idea to do a catch-all except statement,
because it's easy to accidentally mask errors without seeing what they
are. I'd suggest catching CORBA.Exception or CORBA.SystemException and
printing the exception out.

[...]
Post by Kyle Dunn
Problem resolving Panorama object name in initCorbaOrb().panoramaClientInit()
Exception exceptions.AttributeError: "_objref_Panorama instance has no
attribute '_Object__release'" in <bound method _objref_Panorama.__del__ of
<gri._objref_Panorama instance at 0xb79e3c6c>> ignored
I'm not sure why that's happening. Removing the catch-all except might
help by revealing what the exception was.

Do the omniORBpy echo examples work for you? If not, there's something
fundamentally wrong with your omniORBpy build. If they do work, the
problem is something related to what your code is doing. Please create a
minimal example of your code that shows the problem and post the
complete thing.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Duncan Grisby
2009-04-29 15:48:29 UTC
Permalink
[...]
? File "/home/krdunn2/localPrefix/lib/python2.4/site-packages/
CosNaming_idl.py", line 231, in resolve
??? return _omnipy.invoke(self, "resolve",
_0_CosNaming.NamingContext._d_resolve, args)
? File "/tmp/tmplka8PB", line 900, in __init__
? File "/tmp/tmplka8PB", line 763, in __init__
? File "/tmp/tmplka8PB", line 590, in __init__
TypeError: unbound method __init__() must be called with _objref_Entity
instance as first argument (got _objref_Panorama instance instead)
Exception exceptions.AttributeError: "_objref_Panorama instance has no
attribute '_Object__release'" in <bound method _objref_Panorama.__del__ of
<gri._objref_Panorama instance at 0xb7a074cc>> ignored
Your previous catch-all except block was indeed swallowing the important
error.

The problem is that you are using omniORB.importIDL to import two
separate IDL files, but both those files #import the same file. In that
file, a base interface named "Entity" is defined.

Since importIDL loads each IDL file separately, the definitions from the
second import overwrite the definitions from the first one. That means
you have two separate classes called _objref_Entity, leading to the
error "TypeError: unbound method __init__() must be called with
_objref_Entity instance as first argument (got _objref_Panorama
instance instead)". _objref_Panorama is derived from a different
_objref_Entity than the one that's now present.

There are two ways to fix this. One is to explicitly compile the IDL
with omniidl, rather than doing it dynamically with importIDL(). The
other way is to do a single call to importIDL() (or importIDLString()),
giving it a file with #includes to the two IDL files. That way, all the
classes will be defined at the same time and there won't be any
conflicts.

Cheers,

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