RE: [Zope] Invalidate RAM cahce manager programatically
Ok. What I am doing is rather than get data from the DB directly, I "cache" it in a Zcatalog. This give me the added side benefit of using the ZCTextIndex's search capability for all content on my site as well. How I do this is this: certain SQL methods use classes to massage the result set into a loose class (there are no or few methods on these classes). Then that class is passed to the Zcatalog with it's row_id as the object identifier. Here's the code sample that adds "feature" objects to the catalog (the metadata_ids are unique and constant). Python script catalogItem(metadata_id=0) exists in my feature ZCatalog if metadata_id is not 0: <-- whoops. Just saw this funny, the code seems to work though features = context.sql.feature.getMetadata(metadata_id=metadata_id) else: features = context.sql.feature.getMetadata() for feature in features: print "Cataloging metadata_id: %s<br>" % feature.metadata_id # get my authors and their companies for author in context.sql.feature.getAuthors(metadata_id=feature.metadata_id): print "Adding author: %s<br>" % author.name feature.addAuthor(author) feature.setPreferredTopic(context.sql.feature.getPreferredTopic(feature. metadata_id)) uid = '%s' % feature.metadata_id print "Added to catalog with ID: %s<br>" % uid container.catalog_object(feature, uid) return printed I do this for almost all other "content types" we have here with little or no change. Could that goof with the "is not 0" be the cause for the uncatalog issue? -jim -----Original Message----- From: Chris Withers [mailto:chrisw@nipltd.com] Sent: Wednesday, October 15, 2003 8:47 AM To: Jim Kutter Cc: zope@zope.org Subject: Re: [Zope] Invalidate RAM cahce manager programatically Jim Kutter wrote:
What I discovered was that calling catalog_object doesn't re-catalog the SQL results like I thought it would. I had to uncatalog_object first, then catalog_object to have the changes from the database kick in. I presumed that multiple calls to catalog_object would overwrite the ZCatalog's entry with new data.
They do, you must be doing something pretty weird for this not to work. What does your code which calls catalog_object look like? Chris
Jim Kutter wrote:
I do this for almost all other "content types" we have here with little or no change. Could that goof with the "is not 0" be the cause for the uncatalog issue?
Could be... what happens when you fix it? Chris
participants (2)
-
Chris Withers -
Jim Kutter