Michael Ang wrote:
Hi, I am new to zope3 and zopeproject.
I have a question, how do I create an instance of my (IContainer) class
when initial startup of a zopeproject?

For Plone, I can inject in Extensions/Install.py.

Hope you understand my question, thanks.

Write an IDatabaseOpenedWithRootEvent handler:

import zope.component
from zope.app.appsetup.interfaces import IDatabaseOpenedWithRootEvent
from zope.app.appsetup.bootstrap import getInformationFromEvent

  def createInitialFolder(event):
      db, connection, root, root_folder = getInformationFromEvent(event)
      if 'myfolder' not in root_folder:
          root_folder['myfolder'] = MyContainer()

and register it as a subscriber:

  <subscriber handler="...createInitialFolder" />

http://worldcookery.com -- Professional Zope documentation and training

Zope3-users mailing list

Reply via email to