[Zope-CMF] How to use "typesTool.manage_addTypeInformation" ?

KLEIN Stéphane stephane at harobed.org
Thu May 5 13:40:46 EDT 2005


Hello,

I try to build CMF Product.

I read chapiter 13 "Writing a Product in Python" of "The Definitive 
Guide to Plone" book 
(http://docs.neuroinf.de/PloneBook/ch12.rst?image_scale=narrow).

I look the install method of Extensions/Install.py file.

I the book, I've this code :

def install(self):
	out = []
	typesTool = getToolByName(self, 'portal_types')
	skinsTool = getToolByName(self, 'portal_skins')

	if id not in typesTool.objectIds():
    		typesTool.manage_addTypeInformation(
       			add_meta_type = factory_type_information['meta_type'],
        			id = factory_type_information['id']
        		)
    		out.append('Registered with the types tool')
	else:
		out.append('Object "%s" already existed in the types tool' % (id))

When I use this code, I've this error :

"""
2005-05-05 19:36:33
failed:
Traceback (most recent call last):

   File 
"/home/harobed/newzope/Products/CMFQuickInstallerTool/QuickInstallerTool.py", 
line 235, in installProduct
     res=install()

   File 
"/home/harobed/myzope/lib/python/Products/ExternalMethod/ExternalMethod.py", 
line 232, in __call__
     return f(self.aq_parent.this(), *args, **kw)

   File 
"/home/harobed/newzope/Products/ZHelloWorld/Extensions/Install.py", line 
22, in install
     )

   File "/home/harobed/newzope/Products/CMFCore/TypesTool.py", line 598, 
in manage_addTypeInformation
     raise ValueError, (

ValueError: Meta type ZHelloWorld is not a type class.
"""

ZHelloWorld is my product name.

Now, in source code tarbal example, I've this :

from Products.CMFCore.TypesTool import FactoryTypeInformation as fti_klass

...

def install(self):
	out = []
	typesTool = getToolByName(self, 'portal_types')
	skinsTool = getToolByName(self, 'portal_skins')

	if id not in typesTool.objectIds():
    		typesTool.manage_addTypeInformation(
			fti_klass.meta_type,   			
        			id = plone_product_name
        		)
    		out.append('Registered with the types tool')
	else:
		out.append('Object "%s" already existed in the types tool' % (id))

Here, the value of fti_klass.meta_type is "Factory-based Type Information".

What is the good method ? Why I must add type class with fti_klass 
meta_type name and not my meta_type value ?

Thanks for your help,
   -- Stéphane



More information about the Zope-CMF mailing list