IContextAwareDefaultFactory has wrong context and no Acquisition chain if called in Python

As described here: https://docs.plone.org/external/plone.app.dexterity/docs/advanced/defaults.html
It should be possible to define a defaultFactory which has a context, which should be the parent of the object you are creating.
This works as long you are using the Plone UI to create an object.
But if you create an object in Python with api.content.create or the old invokeFactory way, the context is the object it self and it has no Acquisition chain and therefor no parent.

I created an example addon to show this.


You can run one of the following test to trigger the creation of an object and the defaultFactory.

./bin/test -t test_ct_sample_type_adding
./bin/test -t test_ct_sample_item_adding

The code is here:

If anyone has an idea how this could work, i would be really thankful.
In case this is just a bug I'll report it later on.
But it would really help to get his working as intended.

Plone Foundation Code of Conduct