Mercurial > p > roundup > code
annotate roundup/cgi/PageTemplates/PathIterator.py @ 8566:e4191aa7b402 default tip
doc: issue2551415 correct doc for change input->input_payload
in 2.5 the rest interface changed a variable name from input to
input_payload. An earlier commit changed the rest docs. This commit
adds an item for it to the upgrading 2.4.0->2.5.0 section. Also cross
reference added to the rest docs with the updated examples.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 09 Apr 2026 00:19:06 -0400 |
| parents | 99667a0cbd2d |
| children |
| rev | line source |
|---|---|
| 1049 | 1 ############################################################################## |
| 2 # | |
| 3 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. | |
|
2349
b43efe461b3e
update PageTemplates to latest Zope codebase
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
4 # |
| 1049 | 5 # This software is subject to the provisions of the Zope Public License, |
| 6 # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | |
| 7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | |
| 8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | |
| 10 # FOR A PARTICULAR PURPOSE | |
|
2349
b43efe461b3e
update PageTemplates to latest Zope codebase
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
11 # |
| 1049 | 12 ############################################################################## |
| 13 | |
| 14 """Path Iterator | |
| 15 | |
| 16 A TALES Iterator with the ability to use first() and last() on | |
| 17 subpaths of elements. | |
| 18 """ | |
| 19 | |
|
5388
d26921b851c3
Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4570
diff
changeset
|
20 from . import TALES |
|
d26921b851c3
Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4570
diff
changeset
|
21 from .Expressions import restrictedTraverse, Undefs, getSecurityManager |
| 1049 | 22 |
| 23 class Iterator(TALES.Iterator): | |
| 24 def __bobo_traverse__(self, REQUEST, name): | |
| 25 if name in ('first', 'last'): | |
| 26 path = REQUEST['TraversalRequestNameStack'] | |
| 27 names = list(path) | |
| 28 names.reverse() | |
| 29 path[:] = [tuple(names)] | |
| 30 return getattr(self, name) | |
| 31 | |
| 32 def same_part(self, name, ob1, ob2): | |
| 33 if name is None: | |
| 34 return ob1 == ob2 | |
| 35 if isinstance(name, type('')): | |
|
2349
b43efe461b3e
update PageTemplates to latest Zope codebase
Richard Jones <richard@users.sourceforge.net>
parents:
2005
diff
changeset
|
36 name = name.split('/') |
|
5398
99667a0cbd2d
Python 3 preparation: use list() around filter() as needed.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5388
diff
changeset
|
37 name = list(filter(None, name)) |
| 1049 | 38 securityManager = getSecurityManager() |
| 39 try: | |
| 40 ob1 = restrictedTraverse(ob1, name, securityManager) | |
| 41 ob2 = restrictedTraverse(ob2, name, securityManager) | |
| 42 except Undefs: | |
| 43 return 0 | |
| 44 return ob1 == ob2 |
