[Zope] ZCatalog problem!
Sun, 03 Sep 2000 11:47:10 -0700
Kevin Howe wrote:
> Hi, I have a Folderish class (FClass) and I am trying to write it so that
> when an FClass object is added in ZOPE, it will automatically create a
> ZCatalog object inside itself. I attempted to do this in the manner I had
> successfully done this before with other object types:
> # handle represents the new object to be added with self,_setObject(id,
> handle.manage_addZCatalog('CatName', 'CatTitle, None)
generally i reserve this type of stuff into the __init__ method of the
object... hence i don't clutter up my manage_add method with code thats
not directly relevant to its function.
anyways, such is mainly a style matter..
to answer your question...
here is a method i call from my __init__ method of a python product.
''' setups catalog for searching news channels '''
id = 'news_catalog'
catalog = Products.ZCatalog.ZCatalog.ZCatalog(id)
# setup indexes and such
# get rid of defaults
you can also do it from a dtml-method.
i'd don't have the exact syntax handy...
but i'll take a stab at it
> But this doesn't work. I then did some testing with DTML using the following
> method inside a Folder:
> <dtml-call " manage_addFolder('FolderName') ">
> <dtml-call " manage_addImage('ImageName', '') ">
> <dtml-call " manage_addZCatalog('CatName', 'CatTitle', _.None) ">
> The new Folder and new Image were both added with no problems. This was what
> I expected since the "manage_addFolder" and "manage_addZCatalog" methods are
> inherited from OFS.Folder.Folder. The method "manage_addZCatalog" however,
> doesn't seem to have been inherited for some reason.
the Folder, Image, Document, Method manage_adds are globally available
methods... to add a product you need
see the howto on adding zclasses programamtically for examples/more
if i remember correctly the syntax is something like
<dtml-call "manage_addZCatalog('foo', 'bar', _.None)">
but i would check that...