[omniORB] Python inheritance and inherited interfaces

Gary Pennington Gary.Pennington@uk.sun.com
Tue, 29 Aug 2000 14:11:09 +0100


Hi,

I'm trying to work out the most natural way of using Python with omniORB
and I have a question which I hope somebody can comment on.

Here's the scenario :-

There are basic users and there are more sophisticated users, ie
advanced users. This is modelled with an inheritance hierarchy such that
AdvancedUser inherits from BasicUser. To represent this in idl and make
this functionality available to distributed users I did the following :-

To represent a basic user I defined this interface in the basic module
:-

 interface UserIF {
    string getName();
    string getPass();
    string getFullName();
    string getEmail();
    long getAuth();
    void setPass(in string passw);
    void setFullName(in string fullNamw);
    void setEmail(in string email);
    void setAuth(in long auth);
    boolean validate(in long auth);
    boolean goodAuth(in long auth);
    <etc...>
  };

to represent more sophisticated users I have the following :-

  interface AdvancedUserIF : basic::UserIF{
...extra operations
    e.g.
    string getExtraInformation();
    void addResource(in string resource) raises(basic::InvalidRequest);
    void setSecurity(in string rank) raises(basic::InvalidRequest);
  };

Now, (getting to the Python part/question at last. )

Implementing the basic::UserIF interface is easy, just do as you would
expect :-

class UserImpl(webJudge__POA.UserIF):

However, how should we define the advanced user interface?

I'm doing this :-

import basicServer    #Contains python code for implementing basic
server interface
....
class AdvancedUserImpl(advanced__POA.AdvancedUserIF,
basicServer.UserImpl): #Inherit first from the generated interface and
secondly from the basic implementation
    ...

The order of the inheritance is important, you must inherit the
AdvancedUserIF first, but as long as you do this the above does work.
The question that I have is, is this the correct way to do this kind of
thing, especially wrt  Python?

Thanks for any feedback,

Gary