[Zope-dev] Problems with CatalogAware?

sean.upton@uniontrib.com sean.upton@uniontrib.com
Mon, 10 Sep 2001 09:40:46 -0700


Right now I only call index_object() after an edit, as I was assuming that
after adding things would be automatically taken care fo for me, but
obviously this is not the case.  There are, indeed, default values in some
properties within the class __init__ method.

I think what is happening is that I am indexing methods (not properties),
and since my factory method doesn't call an explicit reindex_object() after
some properties are changed (code below) I am having problems.  I wonder if
I call self[id].index_object() after self._setObject(id, ad) if that will do
the trick?

Thanks for the reply,
Sean

def manage_addAdItem(self, id, title, REQUEST=None):
 """Zope managment interface create method for AdItem"""

 ad=AdItem(id)
 ad.setId(id)
 ad.setTitle(title)
 if REQUEST is not None:
   ad.setAdBody(REQUEST['adBody'])
   if (len(REQUEST['keywords']) > 0):
     ad.setKeys(REQUEST['keywords'])
   ad.setAdDateMulti(yyyy=REQUEST['Adyyyy'], mm=REQUEST['Admm'],
dd=REQUEST['Addd'])
   ad.setRtDateMulti(yyyy=REQUEST['Rtyyyy'], mm=REQUEST['Rtmm'],
dd=REQUEST['Rtdd'])
   ad.featureURL=REQUEST['featureURL']
 self._setObject(id, ad)
 if REQUEST is not None:
   return self.manage_main(self, REQUEST)



-----Original Message-----
From: Toby Dickenson [mailto:tdickenson@devmail.geminidataloggers.co.uk]
Sent: Monday, September 10, 2001 6:28 AM
To: sean.upton@uniontrib.com
Cc: zope-dev@zope.org
Subject: Re: [Zope-dev] Problems with CatalogAware?


On Fri, 31 Aug 2001 15:17:27 -0700, sean.upton@uniontrib.com wrote:

>I have a python product that has a class derived from CatalogAware and
>Folder.  I programmatically add instances of these (1000s of them) on an
>automated basis every day in the early morning.
>
>My problem is that whenever I do this, the Catalog is updated with some
>problems:
>1 - Metadata is skewed: DateTime objects are cataloged, and they end up
with
>the wrong date ('2001/01/01') instead of today's date, even though the
>actual property contains today's date.  The index in question is built from
>a property.
>2 - Text indexes only get a portion of their text stored in the metadata,
>not all of it.  The index in question is built from a class method in the
>product code.
>

Appologies if you already know this.....

CatalogAware will automatically reindex if an object is added,
deleted, or moved. However it does not automatically reindex if
properties are changed.

It sounds like your index might contain the default (initial) values
for these properties. Do you need to add a call to reindex_object()
after changing them from the defaults?

Toby Dickenson
tdickenson@geminidataloggers.com