Re: [Zope] Problem with Automatic Cataloging Example in ZopeBook
Hi Chris, Chris and fellow Zopers, I promised an update on the Automatic Cataloging example in the Zope book, but I was offline for a few days. Sorry for that. So here it is: I had the same problem when I tried the example from the book (even the final version). Also, I used a non-standard name (say myCatalog) for the ZCatalogue, and in this way introduced another problem: The example in the book only works with the standard named Catalog: "Catalog". Finally, the book forgets to add the new properties to the default input form for the newly created newsitem. So, take the following steps. 1. Modify the NewsItem_addForm dtml-method, by adding input fields for the content, author and date properties. You do want to be able to put some newsthings in the new NewsItem. 2. Modify the standard <dtml-with ...> tag in the NewsItem_add dtml-method: <dtml-with "NewsItem.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "manage_editCataloger('myCatalog')"> <dtml-call "propertysheets.News.manage_editProperties(REQUEST)"> <dtml-call reindex_object> </dtml-with> **manage_editCataloger('myCatalog') tells the newsitem constructor which Catalog is to be used to index the newsitem. When you omit this line, the name of the catalog used, will default to "Catalog". **propertysheets.News.manage_editProperties(REQUEST) writes the values from the manage_addForm newsitem properties, to the newly created newsitem; **reindex_object tells the catalogue to re-index this newsitem. Why is this nessecary? Because when the newsitem is constructed, it is auto-added to the catalog, but at that stage, the properties do not contain the addForm data yet: take a look at the first few lines of the manage_afterAdd method in CatalogAwareness.py: def manage_afterAdd(self, item, container): self.index_object() .... etcetera This should do the trick. However, it seems unlogical to me that we should reindex a catalogaware class, on creation of a new item. Would'nt it make more sense, that the cataloging takes place, only after the properties take their initial values? Greetings to all, Antwan. At 11:28 AM 5/16/01 +0900, you wrote: Hi fellow Zopers, I've been running in some problems with Cataloging and went to the ZopeBook to see whats wrong. In trying to work through the examples in Chapter 9, Automatic Cataloging, I found that with the latest and greatest Zope 2.3.2, the Catalog fails to acquire and catalog the properties of my NewsItem. Just to verify that I am not doing something very stupid wrong, I went through the same exercise with an old Zope 2.2.1 I had lying around. No problem there, the Catalog looks as expected. Has anybody else run into this or a similar problem? Is it a bug in the ZOpeBook in ZOpe or in my (unplugged) brain? Any help appreciated, Chris -- Institute for Research in Humanities, Kyoto University 47 Higashiogura-cho, Kitashirakawa, Sakyo-ku, Kyoto 606-8265, JAPAN _______________________________________________ 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 )
participants (1)
-
Antwan Reijnen