[omniORB] Attributes in omniORBpy

Duncan Grisby duncan@grisby.org
Sat Nov 23 19:17:00 2002


On Thursday 21 November, Leandro Fanzone wrote:

> Attributes in omniORBpy are mapped as methods (_get_/_set_). Though I 
> know the OMG specification says it must be so, I thought that it would 
> be useful to also have a direct mapping using the 
> __setattr__/__getattr__ technique; these methods could call the 
> "official" methods using exec, for example. In this way we could access 
> the attributes from a client in a more straightforward fashion than 
> calling methods. I'm sure you already gave this some thought; did you 
> find something that prevented this from being done?

There are two main reasons for not using __getattr__ and __setattr__
for attributes. First, it makes life extremely awkward for the server
side when there is inheritance involved. This is made slightly easier
by the new slots mechanism, but it's still ugly.

The second, and in my opinion more important, reason is that it is
dangerous to make a remote call look like a local attribute access.
Of course in Python it's always possible to make something that looks
like an attribute access do lots of processing, but it's not generally
the done thing. One of the great things about Python is that its code
is very readable, and it's generally obvious what a particular piece
of code is doing. The semantics of CORBA attributes are fundamentally
different from those of Python attributes, so dressing the former up
to look like the latter is, I think, unnecessarily confusing.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan@grisby.org     --
   -- http://www.grisby.org --