Commit e957faf1 authored by Guido van Rossum's avatar Guido van Rossum

Add an API to interpret a macro name: findMacroDocument(macroName)

returns a tuple (doc, localName) where doc is a DOM tree, or None if
the current DOM tree should be searched, and localName is the name of
the macro inside that tree.
parent 7403cc42
...@@ -151,3 +151,18 @@ class DummyEngine: ...@@ -151,3 +151,18 @@ class DummyEngine:
def evaluateSequence(self, expr): def evaluateSequence(self, expr):
return self.evaluate(expr) return self.evaluate(expr)
def findMacroDocument(self, macroName):
if not macroName:
print "Empty macro name:", macroName
return None, None
i = string.rfind(macroName, '/')
if i < 0:
# No slash -- must be a locally defined macro
return None, macroName
else:
# Up to last slash is the filename
fileName = macroName[:i]
from Products.ParsedXML.DOM import ExpatBuilder
doc = ExpatBuilder.parse(fileName, 1)
return doc, macroName[i+1:]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment