[Zope-CMF] ?Adding ZClasses registered as Portal Types

Tim Hoffman timhoffman@cams.wa.gov.au
Wed, 22 Aug 2001 11:47:30 +0800


Hi

I am trying to write a bulk importer tool for some customer CMF types.
Basically it reads an XML file and creates a series of nested CMF content.

I have the tool, I can invoke it etc.. but when it comes to adding the 
registered types
I am having trouble.

eg

def importPFAXml(self,dir,REQUEST, RESPONSE):

        if path.exists(dir):

           xml_file = path.join(dir,'PFAProject.xml')

           if path.exists(xml_file):

               pfa_project = PfaProject(xml_file)

               pt = getToolByName( self, 'portal_types' )
               pt.constructContent('Folder',pfa_project.getTitle(), 
RESPONSE)

               ... blah blah more stuff follows

Anyway this how I think I am supposed to do it. But I get an error

    (Object: PFAImporter.importPFAXml('/export/home/bu07361/Ballajura Community College',REQUEST,RESPONSE))
    (Info: REQUEST)
  File <string>, line 0, in ?
  File /usr/local/Zope-2.3.3-py21/lib/python/Products/PFAContent/PFAImporter.py, line 63, in importPFAXml
    (Object: PFAImporter)
  File /usr/local/Zope-2.3.3-py21/lib/python/Products/CMFCore/TypesTool.py, line 745, in constructContent
    (Object: Traversable)
  File /usr/local/Zope-2.3.3-py21/lib/python/Products/CMFCore/TypesTool.py, line 468, in constructInstance
    (Object: ElementWithAttributes)
  File /usr/local/Zope-2.3.3-py21/lib/python/Products/CMFCore/TypesTool.py, line 439, in _getFactoryMethod
    (Object: ElementWithAttributes)
AttributeError: (see above)



But if I go to the portal_types tool directly rather than going via 
getToolByName
it does find the constructor method in for my ZClass but doesn't seem to 
pass 'id' correctly to it.
The example above used 'Folder' which is a default type, but I get the 
same result with my
own types.

Can anyone give me some hints.

Rgds

Tim Hoffman