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
2b768f74
Commit
2b768f74
authored
Feb 07, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add evaluateMacro() method, and optional macros argument to
constructor.
parent
4f09969b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
lib/python/TAL/DummyEngine.py
lib/python/TAL/DummyEngine.py
+21
-1
No files found.
lib/python/TAL/DummyEngine.py
View file @
2b768f74
...
...
@@ -89,10 +89,15 @@ Dummy TALES engine so that I can test out the TAL implementation.
import
re
import
string
from
TALVisitor
import
NAME_RE
from
TALVisitor
import
macroIndexer
from
TALCompiler
import
TALCompiler
class
DummyEngine
:
def
__init__
(
self
):
def
__init__
(
self
,
macros
=
None
):
if
macros
is
None
:
macros
=
{}
self
.
macros
=
macros
dict
=
{}
self
.
locals
=
self
.
globals
=
dict
self
.
stack
=
[
dict
]
...
...
@@ -157,6 +162,21 @@ class DummyEngine:
# XXX Should return a sequence
return
self
.
evaluate
(
expr
)
def
evaluateMacro
(
self
,
macroName
):
doc
,
localName
=
self
.
findMacroDocument
(
macroName
)
if
not
doc
:
# Local macro
macro
=
self
.
macros
[
localName
]
else
:
# External macro
macroDict
=
macroIndexer
(
doc
)
if
not
macroDict
.
has_key
(
localName
):
print
"Macro"
,
macroName
,
"not found"
return
macroNode
=
macroDict
[
localName
]
macro
,
dummy
=
TALCompiler
(
macroNode
)()
return
macro
def
findMacroDocument
(
self
,
macroName
):
if
not
macroName
:
print
"Empty macro name:"
,
macroName
...
...
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