[Zope] How to filter and sort PropertyObjects from ZCatalog

  • Thread starter Christian Otteneuer
  • Start date
C

Christian Otteneuer

Hallo NG,

Hope, that I'm not totally wrong in this newsgroup. I have a question about
PropertyObjects in Zope:

I want to get some PropertyObjects out of a ZCatalog.

This Code:
result = (map( lambda brain: brain.getObject(),
container.Catalog.searchResults()))

returns me a list of all Objects in the Catalog, which are, in this case
PropertyObjects.

These PropertyObjects have a property 'priority' (type: int) , which I can
access with:

result[0].getProperty('priority')

Now, I want to filter out all PropertyObjects, which have 'priority == 0'
and sort all other POs by 'priority',
so that I finally have a list like this:

result[0].getProperty('priority') == 1
result[1].getProperty('priority') == 2
result[2].getProperty('priority') == 3
....

Does anyone know, how to reach such a list
a) by changing the query to the ZCatalog with 'filters' and 'sort
algorithms'
or
b) by changing my list 'result' ??

Thanks alot
 
C

Christian Otteneuer

Now, I want to filter out all PropertyObjects, which have 'priority == 0'

For the 'filter problem', I found a possibility:

result = (map( lambda brain: brain.getObject(),
filter(lambda x: x.getObject().getProperty('priority')>0,
container.Catalog.searchResults())))

Stays the 'sort problem'...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top