Date: Sun, 18 Jan 2004 00:12:58 +0100 From: Dieter Maurer <dieter@handshake.de> Subject: Re: [Zope] ZClass Catalog Update
KJZZ Webmaster wrote:
I created the following DTML method in the "methods" folder of a ZClass:> <dtml-call "Catalog.manage_catalogReindex(REQUEST, RESPONSE, URL1)"> <dtml-call expr="RESPONSE.redirect(URL1)"> </dtml-let>
I then created an "update" tab which calls this method from the "views" folder.
2) What is the best way to deal with the permissions for this?
Dieter Maurer wrote:
A proxy role (read about them in the Zope Book, 2.6 edition).
Thank you for pointing this out. If I go into the DTML method I created in the "methods" folder of my ZClass and change the Proxy Role to Manager, it works just like it should!
1) Is there a way to update only the individual ZClass object in the catalog
The method is "catalog_object" -- it, too, has a well chosen name ;-)
I have some questions about this, if the object is already in the catalog and just needs to be updated. Would I still use this method, or would this create an additional object in the database? I found the following python script which mentions how to use the catalog_object method: http://www.zopera.org/Members/Caro07/updatecatalog request = context.REQUEST catalog = context.Catalog myobject = getattr (context, id) catalog.catalog_object (myobject, id) However, when I try using this, I receive an error saying that "global name 'id' is not defined" Do you have any suggestions on how to I might implement this correctly? Thanks! John T.
KJZZ Webmaster wrote at 2004-1-24 12:04 -0700:
...
1) Is there a way to update only the individual ZClass object in the catalog
The method is "catalog_object" -- it, too, has a well chosen name ;-)
I have some questions about this, if the object is already in the catalog and just needs to be updated. Would I still use this method, or would this create an additional object in the database?
You call this same object and it does the right thing whether the object is new or already known.
... I found the following python script which mentions how to use the catalog_object method:
http://www.zopera.org/Members/Caro07/updatecatalog
request = context.REQUEST catalog = context.Catalog
myobject = getattr (context, id) catalog.catalog_object (myobject, id)
However, when I try using this, I receive an error saying that "global name 'id' is not defined"
In general, you should *NOT* follow this example! The example assumes that 1. you locate the object to be indexed via its "id" from "context" (this is rarely the case) 2. you want the object to be indexed with "id" as its unique id (this is almost never the case). Of course, "id" must come from somewhere. As in your script, it is not defined, you get the error. A better example would be: 1. obtain the object "obj" to be indexed by any adequate way (through a search, via its id (as shown above), via "restrictedTraverse", ... 2. call "catalog.catalog_object(obj)" to catalog (or re-catalog when it already is catalogued) the object -- Dieter
-- Original Message -- From: Dieter Maurer <dieter@handshake.de> A better example would be:
1. obtain the object "obj" to be indexed by any adequate way (through a search, via its id (as shown above), via "restrictedTraverse", ...
2. call "catalog.catalog_object(obj)" to catalog (or re-catalog when it already is catalogued) the object
-- Dieter
In trying to get a bit closer with this, I am using the following script, which can be found here: http://www.zopelabs.com/cookbook/1032051394 catalog = context.Catalog if obj is None: obj=context # print obj # print obj.title_or_id(), ' prints the title or id of the object' catalog.catalog_object(obj) # return printed Yet, after the script has run, I do not get an error, but the individual entry does not update in the catalog. Is it true I should be sending, for instance, the following obj "<story instance at 11A9D3E0>" to the catalog_object method? Or should I be doing something else. Appreciate the help. John T.
KJZZ Webmaster wrote:
http://www.zopelabs.com/cookbook/1032051394
catalog = context.Catalog if obj is None: obj=context # print obj # print obj.title_or_id(), ' prints the title or id of the object' catalog.catalog_object(obj) # return printed
Yet, after the script has run, I do not get an error, but the individual entry does not update in the catalog.
How are you passing the object into this script? What leads you to believe the catalog has not been updated?
Is it true I should be sending, for instance, the following obj "<story instance at 11A9D3E0>" to the catalog_object method?
If you want to catalog your story object, then yes :-) cheers, Chris
http://www.zopelabs.com/cookbook/1032051394
catalog = context.Catalog if obj is None: obj=context # print obj # print obj.title_or_id(), ' prints the title or id of the object' catalog.catalog_object(obj) # return printed
Yet, after the script has run, I do not get an error, but the individual entry does not update in the catalog.
Chris Withers wrote:
How are you passing the object into this script?
What leads you to believe the catalog has not been updated?
If, in one browser window, I make a change in say, the description field, of the item I'm working on, then click on the "update" tab (which calls the script above). Then, in another browser window, I look at the contents of the catalog, and click on link to view the metadata for this item (the link which ends with something like '?rid=-387120426'), the description field does not reflect this change. Could it be that only the Index gets updated and not the Metadata? Could it be that only a certain part of the object like the PrincipiaSearchSource updates?
Is it true I should be sending, for instance, the following obj "<story instance at 11A9D3E0>" to the catalog_object method?
If you want to catalog your story object, then yes :-)
Well, that was simple : ) Thanks! JT
KJZZ Webmaster wrote:
the script above). Then, in another browser window, I look at the contents of the catalog, and click on link to view the metadata for this item (the link which ends with something like '?rid=-387120426'), the description field does not reflect this change.
You sure that page isn't being cached by your web browser? cheers, Chris
KJZZ Webmaster wrote at 2004-1-25 19:58 -0700:
... In trying to get a bit closer with this, I am using the following script, which can be found here:
http://www.zopelabs.com/cookbook/1032051394
catalog = context.Catalog if obj is None: obj=context # print obj # print obj.title_or_id(), ' prints the title or id of the object' catalog.catalog_object(obj) # return printed
Yet, after the script has run, I do not get an error, but the individual entry does not update in the catalog.
Is it true I should be sending, for instance, the following obj "<story instance at 11A9D3E0>" to the catalog_object method? Or should I be doing something else.
"obj" must be the object you want to get recatalogued, whatever this might be... It must be the object itself, not a string representation for it. Note, that you must first modify your object and only then recatalog it. When you recatalog before the modification, nothing will happen (with the catalog). -- Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
KJZZ Webmaster