Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0f58fc15
Commit
0f58fc15
authored
Mar 16, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove code for working with DOM trees.
Move quote() function here from TALInterpreter.
parent
4db70e76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
51 deletions
+8
-51
lib/python/TAL/TALDefs.py
lib/python/TAL/TALDefs.py
+8
-51
No files found.
lib/python/TAL/TALDefs.py
View file @
0f58fc15
...
...
@@ -156,54 +156,11 @@ def splitParts(arg):
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)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment