I quite often need to do something like:
results = MyCatalog(meta_type='Person',continent='Africa').uniqueValuesFor('FirstName')
...which would give you the minimal list of firstnames of people who live in Africa. A bit contrived but I seem to bump into lots of real world cases where I need to do similar.
What I currently have to do is the brutal and slow approach of "walk through the results" :-S
But Anthony came up with a great suggestion:
What would make more sense (maybe?) is results = MyCatalog(meta_type='Person',continent='Africa',uniqueValuesFor='FirstName')
What do other people think? Is there a nice fast way of implementing this?
cheers,
Chris
Chris Withers wrote:
I quite often need to do something like:
results = MyCatalog(meta_type='Person',continent='Africa').uniqueValuesFor('FirstName')
...which would give you the minimal list of firstnames of people who live in Africa. A bit contrived but I seem to bump into lots of real world cases where I need to do similar.
What I currently have to do is the brutal and slow approach of "walk through the results" :-S
But Anthony came up with a great suggestion:
What would make more sense (maybe?) is results = MyCatalog(meta_type='Person',continent='Africa',uniqueValuesFor='FirstName')
What do other people think? Is there a nice fast way of implementing this?
cheers,
Chris
possibly, yes. I'll look to add this to my CatalogQuery product. I believe the btrees can be pressed into service here...
Casey Duncan wrote:
possibly, yes. I'll look to add this to my CatalogQuery product. I believe the btrees can be pressed into service here...
Hadn't heard of this CatalogQuery product... where can I find out more?
I think I may have been about to develop something similar, so maybe we can help each otehr out?
cheers,
Chris
Chris Withers wrote:
Casey Duncan wrote:
possibly, yes. I'll look to add this to my CatalogQuery product. I believe the btrees can be pressed into service here...
Hadn't heard of this CatalogQuery product... where can I find out more?
I think I may have been about to develop something similar, so maybe we can help each otehr out?
cheers,
Chris
http://www.zope.org/Members/Kaivo/CatalogQuery
This is my first stab at this. I forsee a much more general query mechanism in the future, but this works better than the stock stuff (for me) and it works today!
Let me know what your ideas are...
Casey Duncan wrote:
http://www.zope.org/Members/Kaivo/CatalogQuery
This is my first stab at this.
Looks cool :-)
I forsee a much more general query mechanism in the future, but this works better than the stock stuff (for me) and it works today!
Let me know what your ideas are...
Ah, well, yours are based around a text-based query system. I just want to build an object-based query system that will let you powerfully and unambigously query a ZCatalog.
So, for example, something like:
brains = catalog.search(Q(myindex='Fish') & Q(blah=1), sort=('date','blah','myindex'), uniqueValuesFor='myindex'))
...if you see what I mean.
What do you think?
cheers,
Chris