After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 107658 - Impossible to aggregate a pure Python CORBA object to a BonoboObject.
Impossible to aggregate a pure Python CORBA object to a BonoboObject.
Status: RESOLVED FIXED
Product: gnome-python
Classification: Deprecated
Component: bonobo
1.99.x
Other Linux
: Normal normal
: ---
Assigned To: Python bindings maintainers
Python bindings maintainers
Depends on: 109973 127909
Blocks:
 
 
Reported: 2003-03-05 16:59 UTC by Gustavo Carneiro
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (276 bytes, text/plain)
2003-03-05 17:03 UTC, Gustavo Carneiro
  Details
preliminary, untested patch; needs more work, probably. (13.79 KB, patch)
2003-04-07 23:55 UTC, Gustavo Carneiro
none Details | Review
custom bonobo object support patch (4.70 KB, patch)
2003-04-15 22:48 UTC, Gustavo Carneiro
none Details | Review
Foreign object support, with conditional compiling. (5.81 KB, patch)
2003-05-24 11:23 UTC, Gustavo Carneiro
none Details | Review
new version of patch, so it doesn't get lost (8.03 KB, patch)
2003-08-24 10:58 UTC, Gustavo Carneiro
none Details | Review
Code that is now in CVS (6.61 KB, patch)
2003-11-25 18:43 UTC, Gustavo Carneiro
none Details | Review

Description Gustavo Carneiro 2003-03-05 16:59:52 UTC
See the test program.  I get the following output:
---------------------------
Traceback (most recent call last):
  • File "test.py", line 22 in ?
    control.add_interface(myobj)
TypeError: BonoboObject.add_interface() argument 1 must be bonobo.Object,
not MyObject
---------------------------
  I think the test program plus error message are self explanatory.
  What this means is that I cannot define and IDL interface, implement it
in python and then aggregate the python object to an exising C object.
  I don't know how to solve this particular problem, but the solution may
lie in a different implementation of bonobo.Object.add_interface. I'll
investigate further, but any help is appreciated!
Comment 1 Gustavo Carneiro 2003-03-05 17:03:25 UTC
Created attachment 14794 [details]
test program
Comment 2 James Henstridge 2003-03-08 06:04:28 UTC
So we need to be able to create a bonobo.Object (as opposed to a
Bonobo.Unknown ...) for the custom interface.

We will need to find out how best to do that.  I hope that doing so
isn't _too_ tied to creating GObject subclasses in C (it does weird
things like putting epv's into the GObject class structs, and then
constructing the vepv from them ...).
Comment 3 Gustavo Carneiro 2003-04-04 15:07:34 UTC
  I'm going to try to create a bonobo.Unknown object, which serves as
a delegate to a PortableServer.Servant (the constructor expects a
servant is input).  bonobo.Unknown will implement
IDL:Bonobo/Unknown:1.0 -- queryInterface(), ref(), unref() -- and also
add_interface().  bonobo.Object.add_interface will be overriden so
that it detects when the new interface being added is a
bonobo.Unknown, in which case a special bonobo API will be used to
aggregate the object reference.
  More details will follow when (if) I get this implemented.
Comment 4 Gustavo Carneiro 2003-04-07 23:55:26 UTC
Created attachment 15548 [details] [review]
preliminary, untested patch; needs more work, probably.
Comment 5 James Henstridge 2003-04-15 13:01:21 UTC
The most pythonic way to handle this is probably to get
add_interface() to take either a bonobo.Object or CORBA.Object as an
argument.  In the CORBA.Object case, it would call
bonobo_object_add_foreign_interface() (once it has been added).
Comment 6 Gustavo Carneiro 2003-04-15 13:22:06 UTC
  I'm thinking it is not enough.  We have to provide an implementation
of the Bonobo::Unknown interface, and make sure the foreign interface
implements that interface.  Two things are required:
  1. Check that CORBA_Object_is_a(obj, "IDL:Bonobo/Unknown:1.0", &ev);
  2. Provide a python base class that implements that interface, by
having the methods ref, unref, queryInterface, that call respectively
bonobo_object_ref, bonobo_object_unref,
bonobo_object_query_local_interface, with the BonoboForeignObject as
argument.  I am considering naming that class bonobo.Unknown.
  Considering these requirements, I'm thinking that
bonobo.Object.add_interface should accept either bonobo.Object or
bonobo.Unknown as argument.  Does that sound reasonable?
Comment 7 James Henstridge 2003-04-15 13:32:17 UTC
I am still not quite sure why this is necessary.  It is a given that
the interface you are implementing in Python will be derived from
Bonobo.Unknown.  That implementation could simply proxy those method
calls onto the equivalent methods of one of the other aggregated
interfaces (one with a C impl).  Have I missed something?
Comment 8 Gustavo Carneiro 2003-04-15 13:49:03 UTC
  Yes, the programmer could do that, but it is better to create a
class that does that automatically, and programmers would derive from
that class.  In C, when you create a BonoboObject you don't have to
worry about proxying interface methods or anything like that; it
happens automatically.  In python, it should be at least as simple as
that.
Comment 9 Gustavo Carneiro 2003-04-15 22:47:37 UTC
  Now that BonoboForeignObject is in libbonobo, the python part
becomes very simple.  The following patch takes James' and Johan's
suggestion of a "mixin" class, i.e. providing a standard BonoboUnknow
implementation through multiple inheritance.
Comment 10 Gustavo Carneiro 2003-04-15 22:48:46 UTC
Created attachment 15755 [details] [review]
custom bonobo object support patch
Comment 11 Gustavo Carneiro 2003-05-24 11:22:43 UTC
  I'm attaching a new version of the patch, that should conditionally
compile with any  version libbonobo.  I haven't tested with 2.2.x, but
I'm confident it would compile.
  However, this new patch depends on the codegen changes in #113638.
Comment 12 Gustavo Carneiro 2003-05-24 11:23:50 UTC
Created attachment 16797 [details] [review]
Foreign object support, with conditional compiling.
Comment 13 Gustavo Carneiro 2003-07-12 19:42:08 UTC
  I'm interesting to develop an application using this stuff.  In
fact, I've already started testing, and it seems to be working fine,
so far.  When can I commit this? ;)
Comment 14 Gustavo Carneiro 2003-08-24 10:58:37 UTC
Created attachment 19471 [details] [review]
new version of patch, so it doesn't get lost
Comment 15 Xavier Ordoquy 2003-11-23 00:12:30 UTC
The patch works well but if you add the line:

print listener.corba_objref().queryInterface("IDL:Bonobo/Unknown:1.0")

at the end of the unknown.py file, you'll notice that it returns

<CORBA.Object 'IDL:Bonobo/PersistStream:1.0' at 0xXXXXXXXX>

Shouldn't it bee 'IDL:Bonobo/Unknown:1.0' ?
Comment 16 Gustavo Carneiro 2003-11-23 11:24:58 UTC
  Well, Bonobo::PersistStream is a subclass of Bonobo::Unknown, so the
result is still correct.
Comment 17 Gustavo Carneiro 2003-11-25 18:40:41 UTC
  James said it was OK to commit, and so I did, but with some changes ;)
The following patch shows exactly what I have committed.  The example
program highlights a BonoboObject/GObject reference counting problem,
which is a different problem altogether and is unrelated to this
patch.  I'll submit a bug report about it too.
Comment 18 Gustavo Carneiro 2003-11-25 18:43:19 UTC
Created attachment 21803 [details] [review]
Code that is now in CVS
Comment 19 James Henstridge 2003-12-14 09:35:59 UTC
Since gjc has committed this, I'll close the bug report.  Any new
issues can be tracked separately.