Warning

This document hasn't been checked for compatibility with current versions of Plone. Use at your own risk.

TypeError: argument 1 must be string in constructor

by Mikko Ohtamaa last modified Dec 30, 2008 03:08 PM
TypeError: argument 1 must be string, not YourTool A construtor seems to take string argument instead of self.

A class constructor has absurd arguments. For me, this came up, when my Tool was unable to initialize itself:

      portal.manage_addProduct[PROJECTNAME].manage_addTool(UsabilityTool.meta_type)
      File "E:\usability\Test\plone2\Data\Products\CMFCore\utils.py", line 427, in manage_addTool
      obj = tool()
      TypeError: argument 1 must be string, not UsabilityTool

Nasty bastard, this was very hard to pin down. UsabilityTool.__init__ seemed to be Python native method-wrapper. I had to poke around class hierarchy a while before founding out that I was using a module instead of a class in the super class declaration:

    from OFS import SimpleItem

    class UsabilityTool(PloneBaseTool, UniqueObject, SimpleItem, Referenceable, PropertyManager):

Here SimpleItem is module instead of a class import. You can fix this:

    from OFS.SimpleItem import SimpleItem