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
de67b0e2
Commit
de67b0e2
authored
Apr 27, 2001
by
Evan Simpson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support action cancellation.
parent
f7a15140
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
26 deletions
+25
-26
lib/python/Products/PageTemplates/TALES.py
lib/python/Products/PageTemplates/TALES.py
+25
-26
No files found.
lib/python/Products/PageTemplates/TALES.py
View file @
de67b0e2
...
...
@@ -87,9 +87,9 @@
An implementation of a generic TALES engine
"""
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
6
$'
[
11
:
-
2
]
import
re
,
sys
import
re
,
sys
,
ZTUtils
from
MultiMapping
import
MultiMapping
NAME_RE
=
r"[a-zA-Z][a-zA-Z0-9_]*"
...
...
@@ -107,40 +107,28 @@ class TALESError(Exception):
self
.
expression
)
return
self
.
expression
class
Undefined
(
TALESError
):
'''Exception raised on traversal of an undefined path'''
class
RegistrationError
(
Exception
):
'''TALES Type Registration Error'''
class
CompilerError
(
Exception
):
'''TALES Compiler Error'''
class
Iterator
:
'''Simple Iterator class for use in Contexts'''
class
Iterator
(
ZTUtils
.
Iterator
):
def
__init__
(
self
,
name
,
seq
,
context
):
ZTUtils
.
Iterator
.
__init__
(
self
,
seq
)
self
.
name
=
name
self
.
seq
=
seq
self
.
_context
=
context
self
.
nextIndex
=
0
def
next
(
self
):
i
=
self
.
nextIndex
try
:
item
=
self
.
seq
[
i
]
except
IndexError
:
return
0
self
.
index
=
i
self
.
nextIndex
=
i
+
1
self
.
_context
.
setLocal
(
self
.
name
,
item
)
return
1
def
number
(
self
):
return
self
.
nextIndex
def
sequence_start
(
self
):
return
self
.
nextIndex
==
1
def
sequence_end
(
self
):
try
:
self
.
seq
[
self
.
nextIndex
]
except
IndexError
:
return
1
if
ZTUtils
.
Iterator
.
next
(
self
):
self
.
_context
.
setLocal
(
self
.
name
,
self
.
seq
[
self
.
index
])
return
1
return
0
class
Engine
:
'''Expression Engine
...
...
@@ -239,14 +227,20 @@ class Context:
ctx
.
clear
()
def
setLocal
(
self
,
name
,
value
):
self
.
_current_ctxts
[
'local'
][
name
]
=
value
if
value
is
not
Undefined
:
self
.
_current_ctxts
[
'local'
][
name
]
=
value
def
setGlobal
(
self
,
name
,
value
):
self
.
contexts
[
'global'
][
name
]
=
value
if
value
is
not
Undefined
:
self
.
contexts
[
'global'
][
name
]
=
value
def
setRepeat
(
self
,
name
,
expr
):
expr
=
self
.
evaluate
(
expr
)
it
=
self
.
_engine
.
Iterator
(
name
,
expr
,
self
)
if
expr
is
Undefined
:
# Not sure of this
it
=
self
.
_engine
.
Iterator
(
name
,
[
Undefined
],
self
)
else
:
it
=
self
.
_engine
.
Iterator
(
name
,
expr
,
self
)
self
.
_current_ctxts
[
'repeat'
][
name
]
=
it
return
it
...
...
@@ -255,6 +249,8 @@ class Context:
expression
=
self
.
_engine
.
compile
(
expression
)
try
:
return
expression
(
self
)
except
TALESError
:
raise
except
:
raise
TALESError
,
(
`expression`
,
sys
.
exc_info
()),
sys
.
exc_info
()[
2
]
...
...
@@ -279,6 +275,9 @@ class Context:
def
getTALESError
(
self
):
return
TALESError
def
getCancelAction
(
self
):
return
Undefined
class
SimpleExpr
:
'''Simple example of an expression type handler'''
def
__init__
(
self
,
name
,
expr
):
...
...
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