RE: [Zope] Sort by content creation date
Here's a really long and complicated answer to your simple question. Perhaps someone else can contribute a more simple piece of wisdom, but for now, here goes: There may be a way to do this; I'm not sure. On the other hands, perhaps you should be using a Catalog for this. You would get more flexible, faster, and scalable sorting and retrieval of what you need. objectValues() will not scale well to thousands of objects, nor provide for flexible sorting or slicing (like: "get the first 20 in date order"). The alternative: you create a FieldIndex in a Catalog for a string rendering of the path of the container of your items (news) (note PathIndex will not work for this at the moment, use a FieldIndex); create a python script that can be acquired by said folder with the same name as your index that outputs that path (perhaps containerPathName()). Store your date in a Catalog metadata field on indexing, and create an index for your date field (docs suggest using a DateIndex; I currently use FieldIndex in some old apps I've done this with, but I think this has drawbacks). You would then be able to use dtml-in on a Catalog query, and sort the search results on a real date value (i.e. Jan 1, 2003 is greater than Dec 31, 2002) or obtain a specific range or batch size. The contents (and backtalk) of chapter 11 of the online Zope Book have a fairly decent amount of info on using Dates in Catalog searches (http://www.zope.org/Documentation/Books/ZopeBook/current/SearchingZCatalog. stx). Best of all, from a performance standpoint, assuming you store just enough info in the metadata fields, you get just enough data to sort on without having to get an object to sort on one of its attributes via Catalog.getObject() or the ObjectManager.objectValues() you use now. Is this making any sense? I haven't tried this exact approach myself, but am in the middle of doing just this to speed up some skins in a CMF site I'm building so that it can scale to handle thousands of objects in a folder (but only show me, say, 20 at a time, and in a given order). Sean -----Original Message----- From: Patrick Romano [mailto:patrickromano@hotmail.com] Sent: Wednesday, August 21, 2002 3:24 AM To: zope@zope.org Subject: [Zope] Sort by content creation date I want to sort a certain number of Kubes by their content creation date, which is DD/MM/YY, but if I do it like that <dtml-in expr="news.objectValues('Kube')" sort="content_creation_date"> the Kubes are sorted by date starting from the left : sorted by DD first. How can I achieve to have it soted by YY without changing the order of my date (DD/MM/YY)? Thanks, Patrick _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (1)
-
sean.upton@uniontrib.com