horrible ZCatalog kludge
O.k., so I want to know how to get a list of all objects in a ZCatalog for which some variable has a non-null value. A star (*) by itself doesn't work, so how to do it? Well, here's my kludge... catalog = container.people.catalog values = [] for value in catalog.uniqueValuesFor('nominator'): if value: values.append(value) print len(catalog(nominator=values)) I feel so dirty... --kyler
Here's an even better way, but you might need to do it in an external method (it may be unavailable in TTW scripts): index = catalog['Indexes'].nominator l = map(None, index.uniqueValues()) ----- Original Message ----- From: "Kyler Laird" <Kyler@Lairds.com> To: <brinegar@purdue.edu>; <cnd@purdue.edu>; <sydelko@purdue.edu> Cc: <zope@zope.org> Sent: Saturday, July 13, 2002 7:28 PM Subject: [Zope] horrible ZCatalog kludge
O.k., so I want to know how to get a list of all objects in a ZCatalog for which some variable has a non-null value. A star (*) by itself doesn't work, so how to do it? Well, here's my kludge...
catalog = container.people.catalog
values = [] for value in catalog.uniqueValuesFor('nominator'): if value: values.append(value) print len(catalog(nominator=values))
I feel so dirty...
--kyler
_______________________________________________ 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 )
Not so much dirty, but slow and not very scalable. See newly minted recipe: http://www.zopelabs.com/cookbook/1026625784 hth, -Casey ----- Original Message ----- From: "Kyler Laird" <Kyler@Lairds.com> To: <brinegar@purdue.edu>; <cnd@purdue.edu>; <sydelko@purdue.edu> Cc: <zope@zope.org> Sent: Saturday, July 13, 2002 7:28 PM Subject: [Zope] horrible ZCatalog kludge
O.k., so I want to know how to get a list of all objects in a ZCatalog for which some variable has a non-null value. A star (*) by itself doesn't work, so how to do it? Well, here's my kludge...
catalog = container.people.catalog
values = [] for value in catalog.uniqueValuesFor('nominator'): if value: values.append(value) print len(catalog(nominator=values))
I feel so dirty...
--kyler
_______________________________________________ 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 )
Not so much dirty, but slow and not very scalable. See newly minted recipe: http://www.zopelabs.com/cookbook/1026625784 hth, -Casey ----- Original Message ----- From: "Kyler Laird" <Kyler@Lairds.com> To: <brinegar@purdue.edu>; <cnd@purdue.edu>; <sydelko@purdue.edu> Cc: <zope@zope.org> Sent: Saturday, July 13, 2002 7:28 PM Subject: [Zope] horrible ZCatalog kludge
O.k., so I want to know how to get a list of all objects in a ZCatalog for which some variable has a non-null value. A star (*) by itself doesn't work, so how to do it? Well, here's my kludge...
catalog = container.people.catalog
values = [] for value in catalog.uniqueValuesFor('nominator'): if value: values.append(value) print len(catalog(nominator=values))
I feel so dirty...
--kyler
_______________________________________________ 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 )
Casey Duncan wrote:
Not so much dirty, but slow and not very scalable.
See newly minted recipe:
This is cool :-) Could it become part of ZCatalog's code? Maybe in UnIndex? cheers, Chris
On Sun, Jul 14, 2002 at 01:54:08AM -0400, Casey Duncan wrote:
Not so much dirty, but slow and not very scalable.
...but it doesn't require an External Method.
See newly minted recipe:
Let me know when it's part of ZCatalog. Thank you. --kyler
What's wrong with external methods, are you running under restricted FS access? Trust me, for time sensitive code, running it in external Python is the only way to fly. I imagine once I get time to get query objects off the ground, this capability will be part of the core. Until then, you could also use my CatalogQuery product which also has this capability (and more). -Casey ----- Original Message ----- From: "Kyler Laird" <Kyler@lairds.com> To: "Casey Duncan" <casey@zope.com> Cc: <brinegar@purdue.edu>; <cnd@purdue.edu>; <sydelko@purdue.edu>; <zope@zope.org> Sent: Sunday, July 14, 2002 1:47 PM Subject: Re: [Zope] horrible ZCatalog kludge
On Sun, Jul 14, 2002 at 01:54:08AM -0400, Casey Duncan wrote:
Not so much dirty, but slow and not very scalable.
...but it doesn't require an External Method.
See newly minted recipe:
Let me know when it's part of ZCatalog.
Thank you.
--kyler
On Sun, Jul 14, 2002 at 11:07:44PM -0400, Casey Duncan wrote:
I imagine once I get time to get query objects off the ground, this capability will be part of the core. Until then, you could also use my CatalogQuery product which also has this capability (and more).
Of course! I now recall having seen this long ago when I was considering switching to using ZCatalogs. It is the cleaner answer to a few things I'm trying to accomplish. I'm installing it now. Thank you! --kyler P.S. When will expression grouping be implemented? That would be a big help.
On Monday 15 July 2002 01:27 pm, Kyler Laird wrote:
On Sun, Jul 14, 2002 at 11:07:44PM -0400, Casey Duncan wrote:
I imagine once I get time to get query objects off the ground, this capability will be part of the core. Until then, you could also use my CatalogQuery product which also has this capability (and more).
Of course! I now recall having seen this long ago when I was considering switching to using ZCatalogs. It is the cleaner answer to a few things I'm trying to accomplish. I'm installing it now.
Thank you!
--kyler
P.S. When will expression grouping be implemented? That would be a big help.
CatalogQuery is something of an evolutionary dead-end. I don't intend to enhance it any further myself. Implementing expression grouping would mean rewriting the expression parser entirely. The current implementation is just a dumb regex. What I do intend to do is implement a Python expression based query syntax so that I don't need my own expression parser. This is what query objects is all about. Query objects will be at a lower level than CatalogQuery is, but they will be much more powerful and allow you to easily write other query dialects on top of them. -Casey
participants (4)
-
Casey Duncan -
Chris McDonough -
Chris Withers -
Kyler Laird