You need to use the same name that you used in the the Dexterity FTI registration.
You can verify what names are registered in the portal_types
tool:
from Products.CMFCore.utils import getToolByName
typestool = getToolByName(context, 'portal_types')
print typestool.listContentTypes()
or visit the portal_types
tool in the ZMI in your browser and look at the list of types there; they are listed as typeid (Type Title)
in the tool. If your type isn't listed there ensure that you properly registered your type first.
Note that for this to work, you need the local component manager set up correctly. Normally, this happens automatically, but if you are using a bin/instance run
script or use bin/instance debug
, that doesn't happen. You need to do that manually in that case:
from zope.app.component.hooks import setSite
from Testing.makerequest import makerequest
app = makerequest(app)
site = app[site_id]
setSite(site)
You may also want to set a current user:
from AccessControl.SecurityManagement import newSecurityManager
user = app.acl_users.getUser('admin').__of__(site.acl_users)
newSecurityManager(None, user)