Hello, I am trying to do a custom sort. I am using: <dtml-tree branches_expr="objectValues(['Folder'])" sort="orderInt" skip_unauthorized> orderInt is an integer property of some folders. I would like the <dtml-tree tag to look up the property of the current folder and sort based on the integer value, but if the property does not exist I would like it to be excluded from the tree. Is there a way to do it? Thanks for any help! __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
--On 2. Oktober 2005 09:43:02 -0700 Alex Renier <goldenray3458@yahoo.com> wrote:
<dtml-tree branches_expr="objectValues(['Folder'])" sort="orderInt" skip_unauthorized>
perhaps <dtml-tree branches_expr="[o for o in objectValues(['Folder'] if hasattr('orderInt')])" sort="orderInt" skip_unauthorized> -aj
Thanks for your help AJ I get this: Error Type: SyntaxError Error Value: invalid syntax (line 1) <dtml-tree branches_expr="[o for o in objectValues(['Folder'] if hasattr('orderInt'))]" sort="orderInt" skip_unauthorized> It doesn't like how I put spaces in objectValues() attributes for " if hasattr..." Is the syntax a bit different? Thanks! --- Andreas Jung <lists@andreas-jung.com> wrote:
--On 2. Oktober 2005 09:43:02 -0700 Alex Renier <goldenray3458@yahoo.com> wrote:
<dtml-tree branches_expr="objectValues(['Folder'])" sort="orderInt" skip_unauthorized>
perhaps
<dtml-tree branches_expr="[o for o in objectValues(['Folder'] if hasattr('orderInt')])" sort="orderInt" skip_unauthorized>
-aj
__________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
Alex Renier wrote:
Thanks for your help AJ I get this:
Error Type: SyntaxError Error Value: invalid syntax (line 1)
<dtml-tree branches_expr="[o for o in objectValues(['Folder'] if hasattr('orderInt'))]" sort="orderInt" skip_unauthorized>
I think that Andreas meant <dtml-tree branches_expr="[o for o in objectValues(['Folder']) if hasattr(o,'orderInt')]" sort="orderInt" skip_unauthorized>
Great thank you both!!! I never knew you could do if-statements like that. --- Chris Beaven <chris@d-designz.co.nz> wrote:
Alex Renier wrote:
Thanks for your help AJ I get this:
Error Type: SyntaxError Error Value: invalid syntax (line 1)
<dtml-tree branches_expr="[o for o in objectValues(['Folder'] if hasattr('orderInt'))]" sort="orderInt" skip_unauthorized>
I think that Andreas meant
<dtml-tree branches_expr="[o for o in objectValues(['Folder']) if hasattr(o,'orderInt')]" sort="orderInt" skip_unauthorized>
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
It's really more a cool way to do lists than if statements :) I recommend reading through some of Dive Into Python (http://diveintopython.org/) for lots more cool hands-on tips on Python programming. Chapter 3 for a good overview of the uses of Python's different data types. Alex Renier wrote:
Great thank you both!!! I never knew you could do if-statements like that.
Chris Beaven wrote:
It's really more a cool way to do lists than if statements :)
It's technically "list comprehension". Sort of a one-line list transform tool.
I recommend reading through some of Dive Into Python (http://diveintopython.org/) for lots more cool hands-on tips on Python programming. Chapter 3 for a good overview of the uses of Python's different data types.
Good advice. --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com/ Enfold Systems, LLC http://www.enfoldsystems.com
participants (4)
-
Alex Renier -
Andreas Jung -
Chris Beaven -
J Cameron Cooper