[Zope] zcatalog/zclass problem.. help!

Martijn Pieters mj@antraciet.nl
Thu, 23 Sep 1999 21:35:43 +0200


At 19:18 23-9-99 , Chris McDonough wrote:
>I've searched the mailing list in vain trying to find someone with this same
>problem...
>
>Here tis:
>
>I've created a ZClass named "News Item", which is, strangely enough, a news
>item.  It has a class, newsClass, that has a property sheet, Properties,
>upon which properties have been developed... including "news", "subject",
>"owner", "date", "department" and a few others.
>
>I've tweaked the methods within this zclass to give me the sort of actions I
>want upon add and edit, etc.
>
>It's based on ZObject and ZClass_for_Catalog_Aware.
>ZClass_for_Catalog_Aware was the first base class when it was created.
>
>Instances of this custom Zclass are placed in folders within my site... I
>have additionally developed a Zcatalog ("Catalog"), which lives at the root
>of the zodb.  Its only contents are news items and it has been indexed on
>all the properties of the news item.  Additionally, metadata properties are
>the same as the indexed properties.
>
>What I want to happen is this... when someone adds an instance of a news
>item, I want it to be immediately added to the zcatalog "Catalog" and become
>visible on the "home" page of the site through dtml like this:
>
><!--#in "Catalog.searchResults()" sort=id reverse--><!--#comment "id" is
>zopetime with underscores, eg. 1999_09_23_13_05_17_4633_US_Eastern-->
><p>
><B><!--#var department--></B> news:<br>
><A HREF="/<!--#var "Catalog.getpath(data_record_id_)"-->"><!--#var
>subject--></A><br>
></p>
><!--#/in-->
>
>Now this sort of works... this dtml snippet will display just "news:" when a
>new instance of the News Item zclass is added to the site, meaning that it
>KNOWS there's a new instance of News Item....  for each news item that gets
>added, it will display another instance of the text "news:".  So on my front
>page, if I have five news items zclass instances in my site, it'll look
>something like this:
>
>news:
>
>news:
>
>news:
>
>news:
>
>news:
>
>
>However, it wont display any of the dynamic content eg. <!--#var
>department-->, <!--#var subject-->, etc. until I go into the Catalog
>Zcatalog and manually update the catalog.  Once I manually update the
>zcatalog, I get content like:
>
>AppDev news:
>This is news.
>
>etc....

Looks like you don't call index_object after adjusting the properties on a 
newly created ZClass. In your costructor DTML Method, after 
manage_changeProperties, do:

   <dtml-call index_object>

This is needed because there is no way for the XClass to detect wether or 
not you are making changes to the object after you added it to the ODB.

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| T: +31 35 7502100 F: +31 35 7502111
| mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
---------------------------------------------