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)
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.
def setup_catalog(self):
''' setups catalog for searching news channels '''
id = 'news_catalog'
catalog = Products.ZCatalog.ZCatalog.ZCatalog(id)
self._setObject(id, catalog)
# setup indexes and such
self.news_catalog.manage_addColumn('description')
self.news_catalog.manage_addColumn('Date')
self.news_catalog.manage_addIndex('Date', 'FieldIndex')
self.news_catalog.manage_addColumn('ChannelName')
self.news_catalog.manage_addIndex('ChannelName', 'FieldIndex')
self.news_catalog.manage_addColumn('link')
self.news_catalog.manage_addIndex('link', 'FieldIndex')
self.news_catalog.manage_addIndex('SearchableText', 'TextIndex')
# get rid of defaults
self.news_catalog.manage_delColumns(['bobobase_modification_time',
'summary'])
self.news_catalog.manage_delIndexes(['bobobase_modification_time',
'PrincipiaSearchSource'])
return 1
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
info.
if i remember correctly the syntax is something like
dtml-with "Control_Panel.Products['ZCatalog']"
dtml-call "manage_addZCatalog('foo', 'bar', _.None)"
/dtml-with
but i would check that...
Cheers
Kapil
___
Zope maillist - [EMAIL PROTECTED]
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 )