|
|
| 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: