[Zpt] CVS: Packages/TAL - TALDefs.py:1.8

guido@digicool.com guido@digicool.com
Fri, 16 Mar 2001 07:17:52 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv19158

Modified Files:
	TALDefs.py 
Log Message:
Remove code for working with DOM trees.

Move quote() function here from TALInterpreter.



--- Updated File TALDefs.py in package Packages/TAL --
--- TALDefs.py	2001/02/15 17:04:41	1.7
+++ TALDefs.py	2001/03/16 12:17:46	1.8
@@ -156,54 +156,11 @@
         del parts[-1] # It ended in a semicolon
     return parts
 
-
-def macroIndexer(document):
-    """
-    Return a dictionary containing all define-macro nodes in a document.
-
-    The dictionary will have the form {macroName: node, ...}.
-    """
-    macroIndex = {}
-    _macroVisitor(document.documentElement, macroIndex)
-    return macroIndex
-
-from xml.dom import Node
-
-def _macroVisitor(node, macroIndex, __elementNodeType=Node.ELEMENT_NODE):
-    # Internal routine to efficiently recurse down the tree of elements
-    macroName = node.getAttributeNS(ZOPE_METAL_NS, "define-macro")
-    if macroName:
-        if macroIndex.has_key(macroName):
-            print ("Duplicate macro definition: %s in <%s>" %
-                   (macroName, node.nodeName))
-        else:
-            macroIndex[macroName] = node
-    for child in node.childNodes:
-        if child.nodeType == __elementNodeType:
-            _macroVisitor(child, macroIndex)
-
-
-def slotIndexer(rootNode):
-    """
-    Return a dictionary containing all fill-slot nodes in a subtree.
-
-    The dictionary will have the form {slotName: node, ...}.
-    """
-    slotIndex = {}
-    _slotVisitor(rootNode, slotIndex)
-    return slotIndex
-
-def _slotVisitor(node, slotIndex, __elementNodeType=Node.ELEMENT_NODE):
-    # Internal routine to efficiently recurse down the tree of elements
-    slotName = node.getAttributeNS(ZOPE_METAL_NS, "fill-slot")
-    if slotName:
-        if slotIndex.has_key(slotName):
-            print ("Duplicate slot definition: %s in <%s>" %
-                   (slotName, node.nodeName))
-        else:
-            slotIndex[slotName] = node
-    for child in node.childNodes:
-        if child.nodeType == __elementNodeType:
-            _slotVisitor(child, slotIndex)
-
-del Node
+import cgi
+_cgi = cgi
+del cgi
+def quote(s):
+    if '"' in s and "'" not in s:
+        return "'%s'" % _cgi.escape(s)
+    else:
+        return '"%s"' % _cgi.escape(s, 1)