[Zope3-Users] NotYet error when creating content during container
creation
Christophe Combelles
ccomb at free.fr
Sun Feb 25 11:07:03 EST 2007
Hello,
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).
The problem:
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
the problem).
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
possible?).
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 :)
Christophe
More information about the Zope3-users
mailing list