I've been spending several hours on a problem which is probably trivial for
advanced zope3ers, but it was not for me, so I'm posting the solution in case
it's useful for someone (I've not found anything on it).
I want to create a folder, and when this folder is created, several subfolders
should be automatically created. And I have a IntId utility. (this is part of
First, I've tried to create the subfolders in the __init__ method of the folder
being created. It does not work and fails with a NotYet error.
Then, I've tried to create the subfolders in the create method of the AddForm,
after the folder has been eventually created. Still too early: NotYet error.
I've also tried to create the subfolders in a subscriber on IObjectCreatedEvent,
but this is equivalent to the previous attempt : NotYet error.
What I've understood is that the transaction that manages the folder is not
finished, and the IntId utility is not yet able to get a connection on the ZODB.
So I've tried to create an adapter to IConnection for my subfolder, so that it
can use the same connection as the folder. But I couldn't. (however it might be
The simple solution is to create the subfolders AFTER the folder has been
eventually ADDED with the add method. So in the AddForm, I've replaced the
create() method with a createAndAdd method. In this method, I've just created my
folder, called add to add it, then only I could create the subfolders and add
them to the folder.
All logic and no magic makes zope3 a great toy :)
Zope3-users mailing list