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
5681cfc7
Commit
5681cfc7
authored
Mar 01, 2006
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved custom traverser into Five
parent
67ec9bb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
70 deletions
+3
-70
lib/python/Products/PageTemplates/PageTemplateFile.py
lib/python/Products/PageTemplates/PageTemplateFile.py
+3
-70
No files found.
lib/python/Products/PageTemplates/PageTemplateFile.py
View file @
5681cfc7
...
...
@@ -32,74 +32,10 @@ from OFS.SimpleItem import Item_w__name__
from
Shared.DC.Scripts.Signature
import
FuncCode
from
zope.tales.tales
import
ExpressionEngine
from
zope.tales.expressions
import
PathExpr
,
StringExpr
,
NotExpr
,
DeferExpr
,
SubPathExpr
from
zope.tales.tales
import
_valid_name
,
_parse_expr
,
NAME_RE
,
Undefined
from
zope.tales.expressions
import
SimpleModuleImporter
from
zope.tales.pythonexpr
import
PythonExpr
from
zope.tales.expressions
import
PathExpr
_marker
=
object
()
def
extendedSimpleTraverse
(
object
,
path_items
,
econtext
):
"""Traverses a sequence of names, first trying attributes then items.
"""
for
name
in
path_items
:
next
=
getattr
(
object
,
name
,
_marker
)
if
next
is
not
_marker
:
object
=
next
elif
hasattr
(
object
,
'__getitem__'
):
try
:
object
=
object
[
name
]
except
:
# FIX bare try..except
object
=
object
.
restrictedTraverse
(
name
)
else
:
# Allow AttributeError to propagate
object
=
getattr
(
object
,
name
)
return
object
class
MyPathExpr
(
PathExpr
):
def
__init__
(
self
,
name
,
expr
,
engine
,
traverser
=
extendedSimpleTraverse
):
self
.
_s
=
expr
self
.
_name
=
name
paths
=
expr
.
split
(
'|'
)
self
.
_subexprs
=
[]
add
=
self
.
_subexprs
.
append
for
i
in
range
(
len
(
paths
)):
path
=
paths
[
i
].
lstrip
()
if
_parse_expr
(
path
):
# This part is the start of another expression type,
# so glue it back together and compile it.
add
(
engine
.
compile
(
'|'
.
join
(
paths
[
i
:]).
lstrip
()))
break
add
(
SubPathExpr
(
path
,
traverser
,
engine
).
_eval
)
def
Engine
():
e
=
ExpressionEngine
()
reg
=
e
.
registerType
for
pt
in
MyPathExpr
.
_default_type_names
:
reg
(
pt
,
MyPathExpr
)
reg
(
'string'
,
StringExpr
)
reg
(
'python'
,
PythonExpr
)
reg
(
'not'
,
NotExpr
)
reg
(
'defer'
,
DeferExpr
)
e
.
registerBaseName
(
'modules'
,
SimpleModuleImporter
())
return
e
Engine
=
Engine
()
class
PageTemplateFile
(
SimpleItem
,
Script
,
PT
,
Traversable
):
""" A Zope 2-aware wrapper class around the Zope 3 ZPT
PageTemplateFile implementation.
"""
func_defaults
=
None
func_code
=
FuncCode
((),
0
)
...
...
@@ -225,9 +161,6 @@ class PageTemplateFile(SimpleItem, Script, PT, Traversable):
"""
return
None
def
pt_getEngine
(
self
):
return
Engine
def
__getstate__
(
self
):
from
ZODB.POSException
import
StorageError
raise
StorageError
,
(
"Instance of AntiPersistent class %s "
...
...
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