omniORBpy / IDL mapping question...
Dag Sunde
dag at orion.no
Tue Sep 26 08:06:38 EDT 2000
This is scary :-)...
The sample you give on how to do it is _almost_
identical to what I did... including the "print"
messages for testing...
I was a little off-track, since I come from Delphi/VB with
their "Properties"...
Thank you!!! You have saved my day by confirming this one.
And not to mention the language-mapping, which I would have never found
myself...
(I cant help wondering if I had got this fast and good response
if I had this problem in C++, and had asked our commercial
CORBA-vendor (IONA) about the same...)
Gratefully yours...
Dag Sunde
Orion Systems As
Arendal, Norway
"Duncan Grisby" <dgrisby at uk.research.att.com> wrote in message
news:8qq0nl$ngv$1 at pea.uk.research.att.com...
> In article <MM_z5.61$Uc.6635 at juliett.dax.net>, Dag Sunde <dag at orion.no>
wrote:
>
> > interface MarketInterface
> > {
> > readonly attribute CosNaming::Name CorbaName;
> > readonly attribute string NamingDef;
> >
> > attribute string MarketNameLong;
> > attribute string MarketNameShort;
> > ...
> > };
> >
> >This ends up as the following in the generated Python-stubs
> >from the IDL-compiler:
>
> You shouldn't really bother to look at the generated code -- it will
> only confuse you :-) Most of it is magic which only makes sense if
> you look at the C++ code which does the majority of the work.
>
> What you should actually look at is the Python language mapping spec
> at
>
> http://cgi.omg.org/cgi-bin/doc?ptc/00-04-08
>
> [...]
>
> >My problem is: how do I implement the Attributes from the IDL-file,
> >so they behave like attributes when I'm implementing the
> >"MarketInterface" - interface?
> >
> >ie. Mymarket.CorbaName = "Test" or sName = MyMarket.CorbaName ???
>
> The answer is that you don't. CORBA attributes are just a short-hand
> way of specifying a pair of accessor functions (or a single one for
> readonly attributes). CORBA attributes do not behave like Python
> attributes -- they involve a remote call, and can raise CORBA system
> exceptions. The server side need not treat them as attributes -- it
> can do anything it wants inside the operations.
>
> So, on both the client and server sides, you must use _get and _set
> functions:
>
> class MarketInterface_i (_GlobalIDL__POA.MarketInterface):
>
> def _get_CorbaName(self):
> print "getting the CorbaName..."
> return self.CorbaName
>
> def _get_NamingDef(self):
> return self.NamingDef
>
> def _get_MarketNameLong(self):
> return self.MarketNameLong
>
> def _set_MarketNameLong(self, mnl):
> self.MarketNameLong = mnl
>
> def _get_MarketNameShort(self):
> return self.MarketNameShort
>
> def _set_MarketNameShort(self, mns):
> self.MarketNameShort = "Ha! Not the string you thought!"
>
>
> On the client side:
>
> Mymarket._set_MarketNameShort("Hello")
> print Mymarket._get_MarketNameShort()
> ...
>
>
> HTH,
>
> Duncan.
>
> --
> -- Duncan Grisby \ Research Engineer --
> -- AT&T Laboratories Cambridge --
> -- http://www.uk.research.att.com/~dpg1 --
More information about the Python-list
mailing list