Repository: plone/Products.CMFPlone

Issue:
Dexterity Control Panel is missing if site is created without default/example content
Plone 5.0.2



Discussion:
still the case in coredev 5.1

I can confirm this issue; I think the problem is plone.app.contenttypes is not being installed and Dexterity was installed by it.

I can confirm this issue as well with Plone 5.2.0 (5207) running on Ubuntu 18.04 and both Python 3.6.8 & Python 3.7.3.
I got this working with the Help of #1113 and there I entered step by step for other people like my self on how to deal with this as I was having trouble finding steps.

Resolving patch:
diff --git a/Products/CMFPlone/factory.py b/Products/CMFPlone/factory.py
--- a/Products/CMFPlone/factory.py
+++ b/Products/CMFPlone/factory.py
@@ -14,6 +14,7 @@
 
 _TOOL_ID = 'portal_setup'
 _DEFAULT_PROFILE = 'Products.CMFPlone:plone'
+_TYPES_PROFILE = 'plone.app.contenttypes:default'
 _CONTENT_PROFILE = 'plone.app.contenttypes:plone-content'
 
 # A little hint for PloneTestCase
@@ -155,9 +156,11 @@ def addPloneSite(context, site_id, title='Plone site', description='',
     reg['plone.default_language'] = default_language
     reg['plone.available_languages'] = [default_language]
 
-    if setup_content:
-        setup_tool.runAllImportStepsFromProfile(
-            'profile-%s' % content_profile_id)
+    # Install default content types profile if user do not select "example content"
+    # during site creation.
+    content_types_profile = content_profile_id if setup_content else _TYPES_PROFILE
+
+    setup_tool.runAllImportStepsFromProfile('profile-{0}'.format(content_types_profile))
 
     props = dict(
         title=title,


Test patch:
diff --git a/Products/CMFPlone/tests/test_factory.py b/Products/CMFPlone/tests/test_factory.py
--- a/Products/CMFPlone/tests/test_factory.py
+++ b/Products/CMFPlone/tests/test_factory.py
@@ -1,15 +1,20 @@
 # -*- coding: utf-8 -*-
+from plone.dexterity.interfaces import IDexterityFTI
 from Products.CMFPlone.factory import addPloneSite
+from Products.CMFPlone.utils import get_installer
 from Products.CMFPlone.testing import PRODUCTS_CMFPLONE_INTEGRATION_TESTING
+from zope.component import queryUtility
 
 import unittest
 
+
 class TestFactoryPloneSite(unittest.TestCase):
 
     layer = PRODUCTS_CMFPLONE_INTEGRATION_TESTING
 
     def setUp(self):
         self.app = self.layer['app']
+        self.request = self.layer['request']
 
     def testPlonesiteWithUnicodeTitle(self):
         TITLE = 'Ploné'
@@ -34,3 +39,18 @@ def testPlonesiteWithoutUnicodeTitle(self):
         ploneSiteTitle = ploneSite.Title()
         self.assertTrue(isinstance(ploneSiteTitle, str))
         self.assertEqual(ploneSiteTitle, TITLE)
+
+    def test_site_creation_without_content_but_with_dexterity(self):
+        """Test site creation without example content have dexterity installed."""
+        ploneSite = addPloneSite(
+            self.app, 'ploneFoo', title='Foo', setup_content=False)
+        qi = get_installer(ploneSite, self.request)
+        self.assertTrue(qi.is_product_installed('plone.app.dexterity'))
+
+    def test_site_creation_without_content_but_with_content_types(self):
+        """Test site creation without example content have content types."""
+        ploneSite = addPloneSite(
+            self.app, 'ploneFoo', title='Foo', setup_content=False)
+        # Folder
+        fti = queryUtility(IDexterityFTI, name='Folder')
+        self.assertIsNotNone(fti)