[XML-SIG] foo.bar vs. foo.get_bar()

Fred L. Drake, Jr. fdrake@acm.org
Mon, 8 Nov 1999 13:20:02 -0500 (EST)


Ken MacLeod writes:
 > From those who understand the details of the DOM and CORBA specs it's
 > not clear to me yet that using attribute syntax is _not_ also
 > conformant (i.e. the Python IDL binding may have been unnecessarily
 > restricted).  The spec fragments from DOM and CORBA posted here both

  What's conformant is what's in the binding.  Perhaps IDL features
could have been mapped to Python differently, though I do understand
why the current mapping is considered acceptable.  I'm not saying that 
a different binding could not have been written, just that it wasn't.

 > seem to support and allow attribute syntax, as well as providing a
 > convention for languages that don't have attribute syntax or the
 > necessary internals.

  The DOM is merely an application in this arena, and has no impact on 
the CORBA mapping.  Since the DOM is specified in terms of IDL, the
Python DOM implementation is constrained by the adopted mapping.
There is nothing that says the DOM client stubs can't provide the
magic __getattr__ and __setattr__ code, only that it's a (potentially) 
non-portable extension of the mapping.  The DOM server may be more
tightly constrained, but I'm not sure.

 > The DOM IDL uses a "readonly" declaration on some attributes, which
 > would seem to imply that if it weren't declared readonly then it would
 > be updatable or writable.

  Ok, good point.  I was thinking more from the implementation side,
but I don't think that really makes a difference.
  If we have the IDL:

    interface bar {
                 attribute a : int;
        readonly attribute b : int;
    }

then we can expect Python code that's essentially:

    class bar:
        def _get_a(self):
            return self.__a
        def _set_a(self, new_a):
            self.__a = new_a

        def _get_b(self):
            return self.__b


  -Fred

--
Fred L. Drake, Jr.	     <fdrake@acm.org>
Corporation for National Research Initiatives