Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "first" and "last" repeat variables #144

Open
pbauer opened this issue May 3, 2013 · 4 comments
Open

Implement "first" and "last" repeat variables #144

pbauer opened this issue May 3, 2013 · 4 comments
Labels

Comments

@pbauer
Copy link
Contributor

pbauer commented May 3, 2013

Structuring a list of dicts breaks with five.pt (version 2.2.1) but works with zpt.

<ul>
  <tal:block tal:repeat="item items">
    <li tal:condition="repeat/item/first/firstletter">...stuff...</li>
  </tal:block>
</ul>

2013-05-03 13:22:53 ERROR Zope.SiteErrorLog 1367580173.450.957745445615 http://lf40035:8080/site_gvp/glossar/folder_az_view
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Products.Five.browser.metaconfigure, line 476, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 93, in __call__
  Module z3c.pt.pagetemplate, line 163, in render
  Module chameleon.zpt.template, line 257, in render
  Module chameleon.template, line 190, in render
  Module chameleon.template, line 172, in render
  Module 2451715f65317517320d5c747af1236026d34d19.py, line 969, in render
  Module 3580e98adbb55fd133ff057f2d54cd5de82e53b1.py, line 1392, in render_master
  Module 3580e98adbb55fd133ff057f2d54cd5de82e53b1.py, line 612, in render_content
  Module 2451715f65317517320d5c747af1236026d34d19.py, line 956, in __fill_main
  Module 2451715f65317517320d5c747af1236026d34d19.py, line 306, in render_main
  Module 2451715f65317517320d5c747af1236026d34d19.py, line 468, in render_azFolderListing
  Module five.pt.expressions, line 154, in __call__
  Module five.pt.expressions, line 126, in traverse
  Module zope.traversing.adapters, line 136, in traversePathElement
   - __traceback_info__: (<chameleon.tal.RepeatItem object at 0xbeab5d0>, 'first')
  Module zope.traversing.adapters, line 50, in traverse
   - __traceback_info__: (<chameleon.tal.RepeatItem object at 0xbeab5d0>, 'first', ('firstletter',))
LocationError: (<chameleon.tal.RepeatItem object at 0xbeab5d0>, 'first')

 - Expression: "repeat/item/first/firstletter"
 - Filename:   ... me/src/bgp/passtheme/browser/templates/folder_az_view.pt
 - Location:   (46:47)
 - Source:     <li tal:condition="repeat/item/first/firstletter">
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0x96b8050>
               views: <ViewMapper - at 0xb33fb10>
               modules: <instance - at 0xbd8830>
               args: <tuple - at 0x7fc7dfae5050>
               here: <ImplicitAcquisitionWrapper glossar at 0x6629d20>
               user: <ImplicitAcquisitionWrapper - at 0x64e2a50>
               nothing: <NoneType - at 0x778dc0>
               container: <ImplicitAcquisitionWrapper glossar at 0x6629d20>
               request: <instance - at 0x5d18680>
               wrapped_repeat: <SafeMapping - at 0xb334368>
               traverse_subpath: <list - at 0xb3a9368>
               default: <object - at 0x7fc7dfaa8b40>
               loop: {...} (2)
               context: <ImplicitAcquisitionWrapper glossar at 0x6629d20>
               view: <SimpleViewClass from /opt/plone/u480phb/bgp.beirat_buildout/src/bgp.beirattheme/src/bgp/passtheme/browser/templates/folder_az_view.pt folder_az_view at 0xb33ff50>
               translate: <function translate at 0xbdaf7d0>
               root: <ImplicitAcquisitionWrapper Zope at 0x4b91d70>
               options: {...} (0)
               target_language: <NoneType - at 0x778dc0>
@malthe
Copy link
Owner

malthe commented May 3, 2013

That's correct. Neither first or last were ever implemented in Chameleon. I never really understood them I think (although it's documented in the Zope 2 Book).

@pbauer
Copy link
Contributor Author

pbauer commented May 3, 2013

That is unfortunate especially since it's documented in http://chameleon.readthedocs.org/en/latest//reference.html#tal-repeat
I never used first before but now that I see it I like it

@malthe
Copy link
Owner

malthe commented May 3, 2013

That is a little unfortunate. I think it would be great to get it implemented. I'm not sure what it would take mostly because I don't entirely understand what it's supposed to do. I know that with ZPT I always ended up wanting start and end, rather than first and last.

@pbauer
Copy link
Contributor Author

pbauer commented May 3, 2013

I don't think implementing it is up my alley but I'll try to explain it allthough the example from the chameleon-docs is kinda self-explaining:

<div tal:repeat="object objects">
  <h2 tal:condition="repeat.object.first.meta_type"
    tal:content="object.type">Meta Type</h2>
  <p tal:content="object.id">Object ID</p>
  <hr tal:condition="object.last.meta_type" />
</div>

It is expected that each item in objects has the attribute meta_type and that the list is sorted by that attribute. repeat.object.first.meta_typeis true if the object is the first in the linst with the same meta_type.

There does not seem to be a usage of this feature in Plone ootb so we might be able to live with some documentation in http://chameleon.readthedocs.org/en/latest//reference.html#tal-repeat on how to achieve something similar without first or last.

@dataflake dataflake changed the title repeat/item/first/foo seems broken Implement "first" and "last" repeat variables Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants