[Zope-CMF] programmatically add topics when adding a new created type

Carl Rendell cer@sol43.com
Fri, 2 Aug 2002 08:39:43 -0700


On Friday, August 2, 2002, at 06:36  AM, zope-cmf-request@zope.org 
wrote:

> Message: 8
> From: "Al-Muthairi, Abdullah" <Abdullah.Al-Muthairi@INTP.COM>
> To: "'zope-cmf@zope.org'" <zope-cmf@zope.org>
> Date: Thu, 1 Aug 2002 15:02:59 -0700
> Subject: [Zope-CMF] programmatically add topics when adding a new 
> created type
>
> Hi everyone
>
> this is my first post here i would really like some help here.
> i created a new portal type called "Application Documentation" by 
> copying a
> folder type and modifying its actions. It should contain meta data 
> about the
> ineternally developed applications in the company and should also 
> contain 2
> zope topics. One of the topics will be the applications documents 
> and the
> 2nd is user contributions. Every time a new application 
> documentation type
> is created these 2 topics should be created also. Any ideas how to
> automatically create the 2 topics with the creation of the type?

Within the edit script for your product (productName_edit.py), you 
may add lines that create the two new topics:

   # after you've created your new folder object...

   folderObject = getattr(context,'folderName')

   newTopics = {'app_docs'  : { 'id'    :'application_documents'
                              , 'title' : 'Application Documents' }
               ,'user cont' : { 'id'    :'user_contributions'
                              , 'title' : 'User Contributions' }
               }

   for key in newTopics.keys():
       folderObject.invokeFactory(type_name='Topic',
                                  id=newTopics[key][id],
                                  title=newTopics[key][id])

That will get the items created and preserve the name space. Within 
the for loop you can add all of the other calls that you wish to 
set up each topic the way you want to set up each topic, and 
control these by extending the dictionary.

I do this pretty often with products, but not specifically with topics.


> i think it is achieved in the factory method (im still new to CMF 
> and zope)
> which brings us to my 2nd question. where can i find the factory 
> methods of
> the portal types?
>

All of the factory method dictionaries are in the various CMF 
directories. Mainly CMFDefault.

> thank you very much for your time

Carl E. Rendell
Solution43
Information Distribution Consulting        |   "Ahhhh the power of
cer@sol43.com                              |    acquisition"  - Chef Z