[Zope] Problem with Automatic Cataloging Example in ZopeBook

Antwan Reijnen antwan@dexus.nl
Sat, 19 May 2001 11:21:11 +0200


--=====================_4764102==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed


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 )

--=====================_4764102==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<table border=0>
<tr><td width=624></td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>Hi Chris, Chris and fellow Zopers,</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>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:</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>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: &quot;Catalog&quot;. Finally, the book forgets to add the new
properties to the default input form for the newly created
newsitem.</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>So, take the following steps.</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>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.</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>2. Modify the standard &lt;dtml-with ...&gt; tag in the
NewsItem_add dtml-method:</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>&lt;dtml-with
&quot;NewsItem.createInObjectManager(REQUEST['id'],
REQUEST)&quot;&gt;</td></tr>
<tr><td width=624>&lt;dtml-call
&quot;manage_editCataloger('myCatalog')&quot;&gt; </td></tr>
<tr><td width=624>&lt;dtml-call
&quot;propertysheets.News.manage_editProperties(REQUEST)&quot;&gt;</td></tr>
<tr><td width=624>&lt;dtml-call reindex_object&gt; </td></tr>
<tr><td width=624>&lt;/dtml-with&gt;</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>**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
&quot;Catalog&quot;.</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>**propertysheets.News.manage_editProperties(REQUEST)
writes the values from the manage_addForm newsitem properties, to the
newly created newsitem; </td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>**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:</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>def manage_afterAdd(self, item, container):</td></tr>
<tr><td width=624>self.index_object()</td></tr>
<tr><td width=624>.... etcetera</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>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?</td></tr>
<tr><td width=624></td></tr>
<tr><td width=624>Greetings to all, Antwan.</td></tr>
<tr><td width=624></td></tr>
</table>
At 11:28 AM 5/16/01 +0900, you wrote:<br>
Hi fellow Zopers,<br>
<br>
I've been running in some problems with Cataloging and went to the<br>
ZopeBook to see whats wrong. <br>
In trying to work through the examples in Chapter 9, Automatic<br>
Cataloging, I found that with the latest and greatest Zope 2.3.2,
the<br>
Catalog fails to acquire and catalog the properties of my<br>
NewsItem. Just to verify that I am not doing something very stupid<br>
wrong, I went through the same exercise with an old Zope 2.2.1 I 
had<br>
lying around. No problem there, the Catalog looks as expected. <br>
Has anybody else run into this or a similar problem? Is it a bug in<br>
the ZOpeBook in ZOpe or in my (unplugged) brain?<br>
<br>
Any help appreciated,<br>
<br>
Chris <br>
-- <br>
<br>
Institute for Research in Humanities, Kyoto University<br>
47 Higashiogura-cho, Kitashirakawa, Sakyo-ku, Kyoto 606-8265, JAPAN<br>
<br>
<br>
_______________________________________________<br>
Zope maillist - Zope@zope.org<br>
<font color="#0000FF"><u><a href="http://lists.zope.org/mailman/listinfo/zope" eudora="autourl">http://lists.zope.org/mailman/listinfo/zope<br>
</a></font></u>** No cross posts or HTML encoding! **<br>
(Related lists - <br>
<font color="#0000FF"><u><a href="http://lists.zope.org/mailman/listinfo/zope-announce" eudora="autourl">http://lists.zope.org/mailman/listinfo/zope-announce<br>
</a><a href="http://lists.zope.org/mailman/listinfo/zope-dev" eudora="autourl">http://lists.zope.org/mailman/listinfo/zope-dev</a></font></u>
)<br>
</html>

--=====================_4764102==_.ALT--