[XML-SIG] DOM Considered Harmful :-)

Jim Fulton jim@digicool.com
Wed, 05 May 1999 17:11:18 -0400


Greg Stein wrote:
> 
> On Wed, 5 May 1999, Jim Fulton wrote:
> > > I'm tremendously in favor of the model returned by qp_xml.
> >
> > (BTW, could you provide a link to this proposal?
> > I must have deleted the message that contained it.  I'd
> > like to look at it.)
> 
> It's available from my page at: http://www.lyra.org/greg/

Thanks, I'll take a look.

> > Acquisition has worked very well in Zope.  It provides a
> > very nice way to share information in a containment hierarchy.
> > It's only drawback is that it requires use of ExtensionClass,
> > which is actually a bonus. ;)
> 
> :-)
> 
> Is that still a patch to the interpreter, or is it all Python code now?

It never was a patch.  It *is* an extension module. There's an ExtensionClass 
extension module and an Acquisition axtension module, which requires 
the ExtensionClass extension to be around.
 
> I'd be interested to see what kinds of changes would be needed to use the
> acquisition stuff.

Basically, you subclass one of the acquisition base classes
(Explicit or Implict) and then, when you want to refer to a parent
in a child (that has been accesses through a parent), you refer
to the parent via the attribute, aq_parent.  

Given that in DOM (if my vague recollection serves me :) children are
not accessed as attributes, the access methods need to return the children
on the context of the parent, as in:

 import Acquisition

 class MyClass(Acquisition.Explicit):

   def some_method_that_returns_a_child(self, ... whatever):
       ....
        return theChild.__of__(self)

The special method __of__, which comes from a mix-in class
returns one object "in the context of" another.

Jim

--
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
repeats.