[Zope-DB] ZCatalog and SQL Coordination

Paul Resnikoff paulr at stanfordalumni.org
Sat Aug 9 17:20:18 EDT 2003


Perhaps a Zope DB guru has some insight into a problem I have been having
coordinating ZCatalog and SQL DB....I appreciate any input!

(1) My problem:

Want to allow visitors to my site http://www.digitalmusicnews.com search news
articles using a simple search form and results page.

(2) Attempt at solution:

Created a ZCatalog in Zope2.6 installation using documentation from the Zope
Book Chapter 9 and some excellent documentation compiled by "RBickers"
entitled "Cataloging SQL Data and Almost Anything Else":



So far, I have been able to only search the most recently added row of the SQL
database.  However, I am interested in searching the whole DB.

Specific Steps:

(1) Created a ZSQL Method that mapped meta data 'id' 'title' and 'meta_type'
to columns in my DB.  Also combined a few columns of my db and made it
searchable from the index PrincipiaSearchSource.  Specific SQL code I used

SELECT Date, Title, Story,
          concat(Company_1, Company_2, Company_3, Title, Story) as
          'News' as meta_type, Title as title, Story as id
        FROM story

(Company_1, Company_2, Company_3, etc are all columns in my DB)

(2) Named the ZSQL Method "getStorytoCatalog"

(3) Placed the ZSQL Method in the main digitalmusicnews folder, which contains
the index page and various other dtml docs and methods.

(4) Created a ZCatalog Object named "Search", also in the digitalmusicnews
folder in my Zope installation.

(5) Added a python script to trigger a coordination between the ZCatalog
Object and the ZSQL Method, like this:

for News in container.getStorytoCatalog(): container.catalog_object(News, 
print 'story #'
return printed

(6) Using "Find Objects" tab in the ZCatalog Object, I added the ZSQL Method
and Python Script above to the catalog.

(7) Created a storydetails.html page with the following code:

<dtml-var header>
<TD>Title</TD><TD><dtml-var title></TD>
<TD>Story</TD><TD><dtml-var story></TD>

BUT, I am not sure how to make this the search result, especially since I am
using Search and Results pages originally created by the ZCatalog. 

I am able to search the most recently added row in the DB, but that is all. 
So that leads me to think that I am almost there and have some small code

Thanks in advance all for the help!
Paul Resnikoff


More information about the Zope-DB mailing list