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
9c04a0ba
Commit
9c04a0ba
authored
May 10, 2006
by
Philipp von Weitershausen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wire in Zope2-compatible, but much more simple iterator implementation.
parent
39e73938
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
30 deletions
+49
-30
lib/python/Products/PageTemplates/Expressions.py
lib/python/Products/PageTemplates/Expressions.py
+41
-3
lib/python/Products/PageTemplates/PathIterator.py
lib/python/Products/PageTemplates/PathIterator.py
+8
-27
No files found.
lib/python/Products/PageTemplates/Expressions.py
View file @
9c04a0ba
...
...
@@ -17,7 +17,7 @@ for Python expressions, string literals, and paths.
$Id$
"""
from
zope.tales.tales
import
ExpressionEngine
,
Context
from
zope.tales.tales
import
ExpressionEngine
,
Context
,
Iterator
from
zope.tales.expressions
import
PathExpr
,
StringExpr
,
NotExpr
from
zope.tales.expressions
import
DeferExpr
,
SubPathExpr
from
zope.tales.expressions
import
SimpleModuleImporter
...
...
@@ -99,10 +99,48 @@ class ZopeEngine(ExpressionEngine):
kwcontexts
=
contexts
return
ZopeContext
(
self
,
kwcontexts
)
class
ZopeIterator
(
Iterator
):
# these used to be properties in ZTUtils.Iterator.Iterator
@
property
def
index
(
self
):
return
super
(
ZopeIterator
,
self
).
index
()
@
property
def
start
(
self
):
return
super
(
ZopeIterator
,
self
).
start
()
@
property
def
end
(
self
):
return
super
(
ZopeIterator
,
self
).
end
()
@
property
def
item
(
self
):
return
super
(
ZopeIterator
,
self
).
item
()
# these aren't in zope.tales.tales.Iterator, but were in
# ZTUtils.Iterator.Iterator
def
first
(
self
,
name
=
None
):
if
self
.
start
:
return
True
return
not
self
.
same_part
(
name
,
self
.
_last
,
self
.
item
)
def
last
(
self
,
name
=
None
):
if
self
.
end
:
return
True
return
not
self
.
same_part
(
name
,
self
.
item
,
self
.
_next
)
def
same_part
(
self
,
name
,
ob1
,
ob2
):
if
name
is
None
:
return
ob1
==
ob2
no
=
object
()
return
getattr
(
ob1
,
name
,
no
)
==
getattr
(
ob2
,
name
,
no
)
is
not
no
def
createZopeEngine
():
e
=
ZopeEngine
()
#TODO wire in PathIterator.Iterator after fixing it
# e.iteratorFactory = Iterator
e
.
iteratorFactory
=
ZopeIterator
for
pt
in
ZopePathExpr
.
_default_type_names
:
e
.
registerType
(
pt
,
ZopePathExpr
)
e
.
registerType
(
'string'
,
StringExpr
)
...
...
lib/python/Products/PageTemplates/PathIterator.py
View file @
9c04a0ba
...
...
@@ -12,33 +12,14 @@
##############################################################################
"""Path Iterator
A TALES Iterator with the ability to use first() and last() on
subpaths of elements.
BBB 2005/05/01 -- to be removed after 12 months
$Id$
"""
import
TALES
from
Expressions
import
restrictedTraverse
,
Undefs
,
getSecurityManager
class
Iterator
(
TALES
.
Iterator
):
def
__bobo_traverse__
(
self
,
REQUEST
,
name
):
if
name
in
(
'first'
,
'last'
):
path
=
REQUEST
[
'TraversalRequestNameStack'
]
names
=
list
(
path
)
names
.
reverse
()
path
[:]
=
[
tuple
(
names
)]
return
getattr
(
self
,
name
)
def
same_part
(
self
,
name
,
ob1
,
ob2
):
if
name
is
None
:
return
ob1
==
ob2
if
isinstance
(
name
,
type
(
''
)):
name
=
name
.
split
(
'/'
)
name
=
filter
(
None
,
name
)
securityManager
=
getSecurityManager
()
try
:
ob1
=
restrictedTraverse
(
ob1
,
name
,
securityManager
)
ob2
=
restrictedTraverse
(
ob2
,
name
,
securityManager
)
except
Undefs
:
return
0
return
ob1
==
ob2
import
zope.deferredimport
zope
.
deferredimport
.
deprecated
(
"It has been renamed to ZopeIterator and moved to the "
"Products.PageTemplates.Expressions module. This reference will be "
"gone in Zope 2.12."
,
PathIterator
=
"Products.PageTemplates.Expressions:ZopeIterator"
)
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