[Zope] query ZCataolg from python

Chris Muldrow muldrow@mac.com
Mon, 10 Dec 2001 10:58:07 -0500


Here's a piece of code that find all of the items in a catalog for a certain
date and displays some properties in HTML:
dt=context.ZopeTime()
y=dt.year()
m=dt.month()
d=dt.day()
dt=y*10000+m*100+d
for stories in context.Catalog({'CreationDate' : dt, 'sort_on' :
'Category'}):
    if stories.title != '':
        storytitle=stories.title
    else:
        storytitle='<font color="red"><b>Headline not available</b></font>'
    if stories.Summary != '':
        storysummary=stories.Summary
    else:
        storysummary='<font color="red"><b>Summary not available</b></font>'
    if stories.StoryName:
        storyname=stories.StoryName
    else:
        storyname='<font color="red"><b>No story name</b></font>'
    titles=titles+' <h3> '+storytitle+' </h3><b>SUMMARY:</b>\n
'+storysummary+' <br><b>LOCALITY:</b>\n '+stories.Locality+'
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>CATEGORY:</b>\n '+stories.Category
    titles=titles+' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>USER:</b>\n
'+stories.User+'<br>\n'
    titles=titles+' <b>Story Name:</b> '+storyname+'<br>\n'
    for pics in stories.PhotosList:
        titles=titles+' <b>Story pictures: </b>\n'+pics+'<br>'
    titles=titles+'<hr>'
return titles




on 12/10/01 10:55 AM, Horst Wald at horstwald@hotmail.com wrote:

> Hi,
> 
> how can I query a ZCatalog from a python script? A code example would be
> welcome.
> 
> Thanks in advance
> 
> Horst
> 
> _________________________________________________________________
> Downloaden Sie MSN Explorer kostenlos unter http://explorer.msn.de/intl.asp
> 
> 
> _______________________________________________
> 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 )