I started my Zope with bin/instance debug
and tried:
>>> from Products.CMFCore.utils import getToolByName
>>> root = app.plone
>>> types_tool = getToolByName(root, 'portal_types')
>>> type_name = 'MyTypeOne'
>>> type_info = portal_types.getTypeInfo(type_name)
>>> type_info
<DynamicViewTypeInformation at /plone/portal_types/MyTypeOne>
>>> tmp_folder = root.temp
>>> new_content_item = type_info._constructInstance(tmp_folder, 'shiny_new_object')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/zope/eggs/Products.CMFCore-2.2.7-py2.7.egg/Products/CMFCore/TypesTool.py", line 546, in _constructInstance
m = self._getFactoryMethod(container, check_security=0)
File "/opt/zope/eggs/Products.CMFCore-2.2.7-py2.7.egg/Products/CMFCore/TypesTool.py", line 462, in _getFactoryMethod
self.getId())
ValueError: Product factory for MyTypeOne was invalid
So, my product factory is invalid. But in which way; how should it look like?
In my profile/default/
, I have a factorytool.xml
:
<?xml version="1.0"?>
<object name="portal_factory" meta_type="Plone Factory Tool">
<factorytypes>
<type portal_type="MyTypeOne"/>
<type portal_type="MyTypeTwo"/>
</factorytypes>
</object>
types.xml:
<?xml version="1.0"?>
<object name="portal_types"
meta_type="Plone Types Tool">
<object name="MyTypeOne"
meta_type="Factory-based Type Information with dynamic views"/>
<object name="MyTypeTwo"
meta_type="Factory-based Type Information with dynamic views"/>
</object>
One of them type definitions, types/MyTypeOne.xml
:
<?xml version="1.0"?>
<object name="MyTypeOne"
meta_type="Factory-based Type Information with dynamic views"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="title">MyTypeOne</property>
<property name="description">
Some description text which is indeed visible in the types tool
</property>
<property name="content_icon">SomeExisting.png</property>
<property name="content_meta_type">MyTypeOne</property>
<property name="product">MyCompany.MyPackage</property>
<property name="factory">addMyTypeOne</property>
<property name="immediate_view">mytypeone_view</property>
<property name="global_allow">True</property>
<property name="filter_content_types">False</property>
<property name="allowed_content_types">
</property>
<property name="allow_discussion">False</property>
<property name="default_view">mytypeone_view</property>
<property name="view_methods">
<element value="base_view"/>
</property>
<property name="default_view_fallback">False</property>
<alias from="(Default)" to="(dynamic view)"/>
<alias from="index.html" to="(dynamic view)"/>
<alias from="view" to="(selected layout)"/>
<alias from="edit" to="base_edit"/>
<alias from="properties" to="base_metadata"/>
<action title="View"
action_id="view"
category="object"
condition_expr=""
url_expr="string:${object_url}/view"
visible="True">
<permission value="View"/>
</action>
<action title="Edit"
action_id="edit"
category="object"
condition_expr="not:object/@@plone_lock_info/is_locked_for_current_user"
url_expr="string:${object_url}/edit"
visible="True">
<permission value="Modify portal content"/>
</action>
</object>
This should be pretty default; I'm still in the beginning, and of course like to be able to see my content objects before continuing to implement futher behaviour.
Base __init__.py
, largely like created by paster create -t archetype example.archetype
(taken from this old reference manual which, alas! contains some now-broken links):
"""Init and utils."""
from zope.i18nmessageid import MessageFactory
from Products.CMFCore import DirectoryView
from Products.CMFCore import utils as cmfutils
DirectoryView.registerDirectory('skins', globals())
from MyCompany.MyPackage import config
from Products.Archetypes import atapi
from Products.CMFCore import utils
archetypeMessageFactory = MessageFactory(config.PROJECTNAME)
def initialize(context):
"""Initializer called when used as a Zope 2 product.
...
"""
content_types, constructors, ftis = atapi.process_types(
atapi.listTypes(config.PROJECTNAME),
config.PROJECTNAME)
for atype, constructor in zip(content_types, constructors):
utils.ContentInit('%s: %s' % (config.PROJECTNAME, atype.portal_type),
content_types=(atype, ),
permission=config.ADD_CONTENT_PERMISSIONS[atype.portal_type],
extra_constructors=(constructor,),
).initialize(context)
What can I do to find and/or fix the problem?
Any additional information needed?
Thank you!