"Martin v. Loewis" wrote: > > > In PyXML, I currently use > > # Define ReleaseNode in a DOM-independent way > import xml.dom.ext > import xml.dom.minidom > def _releasenode(n): > if isinstance(n, xml.dom.minidom.Node): > n.unlink() > else: > xml.dom.ext.ReleaseNode(n) > > try: > from Ft.Lib import pDomlette > def ReleaseNode(n): > if isinstance(n, pDomlette.Node): > pDomlette.ReleaseNode(n) > else: > _releasenode(n) > _XsltElementBase = pDomlette.Element > except ImportError: > ReleaseNode = _releasenode > from minisupport import _XsltElementBase > > This code knows how to release minidom, 4DOM, and pDomlette nodes, and > supports installations without 4Suite (i.e. without pDomlette). I've > put this into xslt/__init__.py, so that all callers of > Ft.Lib.pDomlette.ReleaseNode now need to call xml.xslt.ReleaseNode. > If desired, I could produce a patch against the public Ft CVS. What if we put these on the implementation, that or came up with a standard interface on the node. Then, every DOM imp that wants to be compatible with xpath/xslt needs to support this interface? node.ownerDocument.implementation.releaseNode(node) or node.py_unlink() > > As a slightly independent question, such a function also ought to > support DOM implementations not known to it; I'm thinking in > particular of the Zope DOMs. I'd like to hear proposals on how such an > interface should work; I see three options: See above > > a) it is an operation on the document node (or any node), as in minidom. > b) it is an operation on the DOM implementation (almost as in 4Suite; > you'd need to navigate from the node to the implementation, then > you'd need a well-known operation on the implementation) > c) the code assumes that no release activity is necessary for unknown > DOMs, effectively believing in reference counting, garbage collection, > acquisition, and other black art. I like either a or b Mike > > Any comments appreciated, in particular > 1. from the Ft maintainers on introducing xml.xslt.ReleaseNode, and > 2. from authors of other DOMs on a general memory management API for > Python DOM. > > Regards, > Martin > > _______________________________________________ > 4suite mailing list > 4suite@lists.fourthought.com > http://lists.fourthought.com/mailman/listinfo/4suite -- Mike Olson Principal Consultant mike.olson@fourthought.com (303)583-9900 x 102 Fourthought, Inc. http://Fourthought.com Software-engineering, knowledge-management, XML, CORBA, Linux, Python
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4