[XML-SIG] Ugh! Why are DOM access methods spelled with a leading '_'?

Jim Fulton jim@digicool.com
Fri, 23 Jun 2000 15:51:00 -0400

Mike Olson wrote:
> Jim Fulton wrote:
> >
> > Traditionally, Python attributes (including methods) with
> > names starting with '_' were treated as private.
> >
> > Why oh why then does the Python DOM implementation use
> > method names beginning with '_'s in the public API (for
> > getting attributes), as in '_get_nodeType'? Why not
> > 'get_nodeType' or 'getNodeType'? Is the intent that these
> > functions shouldn't be called by Python code?
> The methods really are not part of the DOM API.

The DOM level 2 recommendation says:
"1.Attributes defined in the IDL do not imply concrete objects which 
must have specific data members - in the language bindings, they are
translated to a pair of get()/set() functions, not to a data member.
Read-only attributes have only a get() function in the language bindings."

This says to me that the DOM API specifies use of methods
for interface attributes.  
> Example: the API defines the attribute nodeType.  the python mapping
> (based off the python CORBA mapping) translates this into _get_nodeType
> for accessors.

I looked at the Python CORBA mapping, but it didn't say anything
about mapping interface-defined attributes. Structure members
are treated as simple Python attributes.
> This interface is not published, but people do use it. 

I think that the benefit of a Python DOM is greatly
reduced if there isn't a well-known (ie published) Python
mapping for it.

> It is encouraged
> that you directly
> access the attributes.

This needs to be specified, not encouraged.  If the '_get_'
methods are part of the interface, then this needs to be spelled out.
If they are *not* part of the interface, then this should be known too.

I personally, would like to have both method and attribute access, but
I'm not happy with public method ames that start with '_'.

> > Is there are description somewhere of the Python DOM mapping,
> > other than the DOM sources?
> I'm not sure if anyone has put together a formal document.  We've based
> most of it off the CORBA mapping at
> http://www.python.org/sigs/do-sig/corbamap.html

I've looked at this several times and don't see a discussion of 
attribute mapping. What section of this are you refering to?

I've also looked at http://www.omg.org/cgi-bin/doc?ptc/00-01-12,
which is similar and also leaves attribute mapping unspecified. :(

Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for