Dexterity object as field of another dexterity object: Works out of the box, but introspection not

Tracked the problem finally down.

Here I stated that if one will user complex properties a ContentFactory for z3c.form has to be registered.

https://community.plone.org/t/how-to-use-dexterity-forms-to-add-a-list-of-custom-objects/3656/2

@implementer(IFoafagent)
class Foafagent(Item):
    """
    """
    portal_type = 'foafagent'

from z3c.form.object import registerFactoryAdapter
registerFactoryAdapter(IFoafgent, FoafAgent)

This is correct but also causes the problems shown in this thread. As Dieter stated the complex properties are not created in the "plone way". And the reason is obviously that the FactoryAdapter I utilized is from z3c.form and does not know much about plone and dexterity.

Here I present a prototype to utilize the dexterity contentFactory instead. There may surely be more elegant solutions.

from z3c.form.object import FactoryAdapter, getIfName
import zope.component
from zope.component.interfaces import IFactory

@implementer(IObjectFactory)
class FoafagentFactory(FactoryAdapter):
    """
    """

    def __call__(self, value):
        factory = queryUtility(IFactory, name='foafagent')
        return factory()

name = getIfName(IFoafagent)
zope.component.provideAdapter(FoafagentFactory, name=name)

This piece of code grabs the registered plone factory utility for the content type (In fact an IDexterityFactory representive aka DexterityFactory instance) and uses it as IObjectFactory adapter for z3c.form.

Utilizing this method complex dexterity properties (as far as I have tested) are working with schema introspection.

Maybe someone is able to help me to intergrate this into dexterity. This registration probably could be made at the time the FTI registration takes place.

Finally thousand thanks @dieter. Without your generous help I would never have discovered this.